These are chat archives for ManageIQ/manageiq/performance

5th
Aug 2016
Nick LaMuro
@NickLaMuro
Aug 05 2016 19:53
PR for speeding up "VMs & Instances in My LDAP Group" filter (and technically others): ManageIQ/manageiq#10290
Already have Keenan taking a look, but opening it up for further discussion here.
Keenan Brock
@kbrock
Aug 05 2016 19:54
yay!
ok, nick, I think I got it
  def owning_ldap_group
    miq_group.try(:description)
  end
turn that into a virtual delegate
so then owned_by_current_ldap_group would be
virtual_attribute :owned_by_current_ldap_group, :boolean, :arel => (lambda (t) do
  t.klass.arel_attribute(:owning_ldap_group).downcase.eq(User.current_user.ldap_group.downcase)
end)
it will be slower
but it will not have any special dependencies
Keenan Brock
@kbrock
Aug 05 2016 19:59
hope downcase works there, wonder if you have to do an arel named function for that.
ugh. we need to fix virtual delegate to work when people write functions named like this
Keenan Brock
@kbrock
Aug 05 2016 20:04
@NickLaMuro this is surgically beautiful
Keenan Brock
@kbrock
Aug 05 2016 20:14
@NickLaMuro I'm getting tired of having virtual_delegate bound to delegate.rb
just like with virtual_total, we have a better implementation of the method (able to read value from the query)
Nick LaMuro
@NickLaMuro
Aug 05 2016 20:17
sorry, playing catchup on two fronts
I will give the above a shot and see if it works
Keenan Brock
@kbrock
Aug 05 2016 20:17
no
can't virtual delegate that method
Nick LaMuro
@NickLaMuro
Aug 05 2016 20:18
oh, okay
that shows us creating a sub query
please make that prettier if you can ;)
line 19 shows how our "delegate" can read a virtual column out of sql instead of fetching the object too
I'll have to bite the bullet sooner or later