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

Refactor: Use page version's element repository rather than a new one #2312

Merged

Conversation

mamhoff
Copy link
Contributor

@mamhoff mamhoff commented Apr 22, 2022

The PageVersion model offers us a repository we can use, so let's go
with that. This will also avoid using a scope on a potentially already pre-loaded association.

Checklist

The `PageVersion` model offers us a repository we can use, so let's go
with that.
@mamhoff
Copy link
Contributor Author

mamhoff commented Apr 22, 2022

Interestingly, the only spot where the element repository from the page version is currently used is when publishing pages. This is done through ActiveJob, and that supports (different to e.g. Sidekiq) passing "objects". Those "objects" however, are still serialized through the GlobalID library, and in the serialization/deserialization process they will lose associated data. The only way to get preloading to work now would be something along these lines in the job:

Alchemy::Page.includes(page_includes).find_by!(id: page.id)

Not pretty, but arguably better to load the page twice (once in GlobalID/ActiveJob, once in our app) than to load all versions, elements, ingredients and so on. What do you think?

Copy link
Member

@tvdeyen tvdeyen left a comment

Choose a reason for hiding this comment

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

Makes total sense. Thanks

@tvdeyen tvdeyen merged commit 756064c into AlchemyCMS:main Apr 26, 2022
tvdeyen added a commit that referenced this pull request Apr 26, 2022
…tory

Refactor: Use page version's element repository rather than a new one
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