-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change extra_data with atomic operations to reduce concurrent problems #14
base: master
Are you sure you want to change the base?
Conversation
10ee32d
to
93fb86d
Compare
93fb86d
to
6182fad
Compare
@@ -43,16 +43,20 @@ | |||
|
|||
|
|||
def add_extra_data(payment, new_extra_data): | |||
payment.refresh_from_db() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this be better?
payment.refresh_from_db() | |
payment.refresh_from_db(fields=["extra_data"]) |
Just to make it more future-proof...
|
||
|
||
def add_new_status(payment, new_status): | ||
payment.refresh_from_db() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't this be better?
payment.refresh_from_db() | |
payment.refresh_from_db(fields=["extra_data"]) |
Just to make it more future-proof...
payment._change_reason = 'PayU Payments: add_new_status' # For django-simple-history | ||
payment.save(update_fields=["extra_data"]) | ||
payment._change_reason = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this (as well as in all the other cases) may be a bit safer:
payment._change_reason = 'PayU Payments: add_new_status' # For django-simple-history | |
payment.save(update_fields=["extra_data"]) | |
payment._change_reason = None | |
payment._change_reason, payment_change_reason_original = 'PayU Payments: add_new_status', payment._change_reason # For django-simple-history | |
payment.save(update_fields=["extra_data"]) | |
payment._change_reason = payment_change_reason_original |
Or maybe
payment._change_reason = 'PayU Payments: add_new_status' # For django-simple-history | |
payment.save(update_fields=["extra_data"]) | |
payment._change_reason = None | |
payment._change_reason = (payment._change_reason or '') + 'PayU Payments: add_new_status' # For django-simple-history | |
payment.save(update_fields=["extra_data"]) | |
payment._change_reason = None |
🤔
But I may be overengineering this...
Pokus o opravu https://github.com/BlenderKit/BlenderKit-server/issues/951