-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Limit children for deletion notice #2491
Limit children for deletion notice #2491
Conversation
5a93245
to
d79d5f7
Compare
c263202
to
28d1770
Compare
28d1770
to
a37fcae
Compare
yield(association, child) | ||
end | ||
children = object.send(association.name) | ||
yield(association, Array.new(children)) |
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.
The problem with this is that it still fetches all children from the database.
I implemented a quick and dirty fix for this here: https://github.com/alexandergitter/rails_admin/commit/6a172da72c98bfd5ca7285b356478a16e7a7a064
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 don't think that children are fetched from database here.
children
variable contains a CollectionProxy
returned to _delete_notice.html.haml
where count
and 'first(limit)
is called. First n children are fetched here.
Am I wrong ?
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.
Mhh that's interesting, I didn't notice that.
In my tests Active Record did an unlimited SELECT though, not sure if there's something else that would trigger that... maybe it's because children gets wrapped in a new array? Would that eagerly fetch all children?
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.
Yes, wrapping children in a a new array may fetch database values.
Seems okay, thanks! |
Limit number of future orphans displayed during deletion confirmation in order to avoid performance issue.