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

AO3-4250 Made gift recipients update on blurbs on pseud / username changes #5063

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

melinath
Copy link
Contributor

Pull Request Checklist

Issue

https://otwarchive.atlassian.net/browse/AO3-4250

Purpose

Made it so that changing a pseud or username, deleting a pseud, or deleting a user account will expire the cache for all gift works (so that the byline will no longer display the old pseud or username.)

For deleting a pseud, this is done by expiring the cache on all gifts for the default pseud (since gifts are reassigned to the default pseud.) This will clear more caches than necessary - technically we only need to expire the cache for the gifts that were previously assigned to pseud being deleted. I did it this way for now because it's easier & keeps all the code in one place, which I think is easier to understand / less likely to break; however, I can definitely go back and change this if desired.

I also tweaked some of the tests related to series blurb updates (to ensure that they behave properly if only the username is updated and no pseuds) and fixed some minor whitespace issues on adjacent tests.

Credit

Stephen Lewis, he/him

Comment on lines +400 to 407
pseud.works.each do |work|
work.touch
work.expire_caches
end
pseud.gift_works.each do |work|
work.touch
work.expire_caches
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The discussion whether touching the works is the right cache busting strategy hasn't quite concluded, but it looks like we were leaning towards it. So, this can be optimized further.

For the gift works, the information is in the blurb. The blurb cache key depends on the work cache key, which depends on the work's updated_at. So it's enough to touch the work to bust the cache, no need to manually do so via expire_caches. That means that this can use the more optimised touch_all instead of looping through the gift works.

Your PR doesn't say why you updated pseud.works to use expire_caches as well, but I think it should be fine to go back to touch_all in this case too.

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

Successfully merging this pull request may close these issues.

2 participants