Skip to content
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

Use an atomic increment for nr_times_visited #22

Merged
merged 2 commits into from
Feb 11, 2025

Conversation

benkonrath
Copy link
Contributor

This update uses an update query with an F expression to atomically increment nr_times_visited. The update query is run using to transaction.on_commit to ensure that the value is only incremented when the current transaction succeeds (transaction.on_commit calls the function immediately if there is no transaction).

I also set DEFAULT_AUTO_FIELD to BigAutoField to silence the warning when running the tests.

Feedback is appreciated. Feel free to also edit the PR if there are changes you want to make.

@alextreme
Copy link
Member

Thanks Ben, appreciate the effort! This is of course a better implementation than what I did years back

@alextreme alextreme self-requested a review February 11, 2025 18:46
@alextreme alextreme merged commit 34d4f09 into maykinmedia:master Feb 11, 2025
12 checks passed
@benkonrath
Copy link
Contributor Author

I think some of this stuff didn't exist in Django back then. :-) Thanks for maintaining this app all these years!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants