-
Notifications
You must be signed in to change notification settings - Fork 356
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
TreeBuilderReportReport reduce queries #1253
Conversation
Looks good to me, but @ZitaNemeckova's review should be the deciding one 😉 |
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.
:icon => "pficon #{@grp_title == r[0] ? 'pficon-folder-close-blue' : 'pficon-folder-close'}", | ||
:tip => r[0] | ||
) | ||
@rpt_menu.each_with_index.each_with_object({}) do |(r, node_id), a| |
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.
Does this still work with count_only
?
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 thought x_get_tree_roots
only called with count_only = true
in rare instances where trees are build from trees.
I added a fix.
Thanks
@kbrock any cc issues you can address? Thx, Dan |
We fetch folders and report for the menu Bring back all folders nodes as a hash (get_tree_roots) Bring back report nodes (get_custom_kids) Added a switch not display reports in the tree. Fixed bug in tree_builder that would force all records to be downloaded at once
@ZitaNemeckova Could you also check the Bug section above? I feel most people don't understand the 3 ways tree builders work and hope to share that information with everyone creating and fixing trees. That list is my primary means of speeding up the left-hand navigation tree. |
Checked commits kbrock/manageiq-ui-classic@d84f42d~...1c50bb5 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
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.
Tested in UI. LGTM 👍
So.. looks like everything works, I also tested a bunch of random trees to catch the treebuilder changes .. 👍 |
Thanks @himdel |
related to #1228
Overview
The page
/reports/explorer
uses many builders, but this PR is only focused on one.TreeBuilderReportReports
is simple:MiqReport
records (names from the menu).Before
After
Numbers
comments
Note: While #1228 and this PR are independent, the numbers seemed more honest if they included that patch in place.
Expanded Reports Numbers
comments
These are the numbers when all report categories are expanded. Since report records are brought back, the
count(*)
savings are lost, but the N+1 really shines through.Please treat these numbers with a grain of salt, it is unlikely that a user will ever expand all levels of the tree and then refresh the screen.
High Git Change count
Since the
@rpt_menu
lookups confused me, I renamed and added many variablesAlso, it seemed simpler to group the category lookups into one method (i.e.:
get_tree_roots
) and the report node lookups into another (e.g.:get_custom_kids
).I can reduce the lines changed significantly if you prefer that route.
Added feature
@dclarizio mentioned that we want to remove report names from the menu. I added a switch (i.e.:
REPORTS_IN_TREE
) to document how to do this.This prevents the report lookup so the worst case numbers go from 803 queries down to the 23.
Bug
Tree builders work in a few ways:
[node1, node2]
, level1 returns[node11, node12]
, level2...{node1 => {node11 => {}, node12 => {}}, node2 => {}}
{node1 => [node11, node12], node2 => []}
, and level2 returns[node111, node 1112]
It turns out that the 3rd use case did not work properly. I made a change in
tree_builder.rb
to address this issue.