Make updating converted prices more robust #92
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Right now the code is quite fragile:
save()method if the converted price or currency is different, if it is, it sets both to default.convert_pricesmethod, and this uses the same way as in thesave()method, which means code duplication.calculate_price_per_gamealso depends on this and is itself very hacky way of determining if an update is needed. It does this by directly querying Django-Q's tableTasksand comparing its last run timestamp with theupdated_atfield of Purchase model.Solutions
needs_price_updatefield to Purchase which would be reset in the model's save method. Being boolean it's unlikely to ever change, and the brittle check inconvert_priceswould just check the value of this field.calculate_price_per_gamebecause if a price has changed we also need to recalculate this.