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
Ensuring article's cache updates on org image update #17052
Conversation
There are three major things occurring in this pull request: 1. Renaming `Article#update_cached_user` to `Article#set_cached_entities`. 2. Reducing an organization's direct knowledge of which of the org's attributes an article caches. 3. Removing duplicate calls to update the article associated with the organization. For renaming to `Article#set_cached_entities`, the prior method implied we were updating the persistence layer. However, we were not making any save nor update calls. This rename should clarify intention. For reducing knowledge, the comments for `Article::ATTRIBUTES_CACHED_FOR_RELATED_ENTITY` should explain the details. And last, removing the duplicate calls; we had three methods that were attempting to build and update the `Article#cached_organization`'s value. Closes #17041
Informed by forem/forem#17052 and forem/forem#17041
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.
I have almost certainly had the same struggles with carrierwave interaction on existing models.
| return unless saved_change_to_attribute?(:name) | ||
|
|
||
| articles.update(cached_organization: Articles::CachedEntity.from_object(self)) | ||
| articles.each(&:save) |
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.
this makes sense given the hook is now "before save". Saving will trigger the expected action.
also, the TODO comment earlier suggested a lot of the existing complication was related to pushing search documents into ES (and we don't do that any more).
|
Confession time, I spent hours 10pm to 11pm fighting with the carrier wave issue. And then from hours 11pm to 7am, as I slept my brain noodled on this. At 8am I said "Alright, let's try a new instance of the object to see if that works." And lo' it did. |
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.
Works like a dream! 🌤️
What type of PR is this? (check all applicable)
Description
There are three major things occurring in this pull request:
Article#update_cached_usertoArticle#set_cached_entities.attributes an article caches.
organization.
For renaming to
Article#set_cached_entities, the prior method impliedwe were updating the persistence layer. However, we were not making any
save nor update calls. This rename should clarify intention.
For reducing knowledge, the comments for
Article::ATTRIBUTES_CACHED_FOR_RELATED_ENTITYshould explain the details.And last, removing the duplicate calls; we had three methods that were
attempting to build and update the
Article#cached_organization'svalue.
Related Tickets & Documents
Closes #17041
QA Instructions, Screenshots, Recordings
My hope is that the tests cover this. To test via the UI, I leave the
following gherkin as guide:
Go to
/and make sure that there's an article with an organization.Now, after the change, look on the dashboard for that article's organization
image. It should have changed.
UI accessibility concerns?
None.
Added/updated tests?
[Forem core team only] How will this change be communicated?