-
-
Notifications
You must be signed in to change notification settings - Fork 315
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
Add Elements repository #2039
Add Elements repository #2039
Conversation
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.
Hm, tests are still failing, please disregard my approval...
@mamhoff and it's a draft PR ;) But I still would like to hear your feedback |
f85b455
to
7819787
Compare
a136a91
to
75da500
Compare
This mimics the ActiveRecord interface of elements, but uses the eager loaded elements and POR methods to filter the collection
It is very common to chain ActiveRecord scopes to filter elements. This makes it possible with the ElementRepository by returning a new instance of the class for each of the scope methods.
These scopes are used on the ElementsFinder and needs to be supported.
This is way fast than using create and since we only use array methods in the repository class its totally safe to use it.
The elements repository uses array methods to filter, order and limit elements on a eager loaded ActiveRecord relation. This should help to prevent N+1 queries in the future.
75da500
to
7ec0b43
Compare
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.
Let's go with this as well!
Rufo uses the same default as Rubocop here. By removing the override we use the dewfault of Rubocop.
7ec0b43
to
9eb1a1d
Compare
What is this pull request for?
Adds a repository class that mimics the ActiveRecord interface of elements, but uses the eager loaded elements and POR methods to filter the collection.
With that we filter the elements in the elements finder (used in the
render_elements
helper) on a eager loaded elements collection.Checklist