{"action":"opened","number":1253,"pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/pulls/1253","id":118890882,"html_url":"https://github.com/ManageIQ/manageiq-ui-classic/pull/1253","diff_url":"https://github.com/ManageIQ/manageiq-ui-classic/pull/1253.diff","patch_url":"https://github.com/ManageIQ/manageiq-ui-classic/pull/1253.patch","issue_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/issues/1253","number":1253,"state":"open","locked":false,"title":"TreeBuilderReportReport reduce queries","user":{"login":"kbrock","id":1930,"avatar_url":"https://avatars1.githubusercontent.com/u/1930?v=3","gravatar_id":"","url":"https://api.github.com/users/kbrock","html_url":"https://github.com/kbrock","followers_url":"https://api.github.com/users/kbrock/followers","following_url":"https://api.github.com/users/kbrock/following{/other_user}","gists_url":"https://api.github.com/users/kbrock/gists{/gist_id}","starred_url":"https://api.github.com/users/kbrock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbrock/subscriptions","organizations_url":"https://api.github.com/users/kbrock/orgs","repos_url":"https://api.github.com/users/kbrock/repos","events_url":"https://api.github.com/users/kbrock/events{/privacy}","received_events_url":"https://api.github.com/users/kbrock/received_events","type":"User","site_admin":false},"body":"# Overview\r\n\r\nThe page `/reports/explorer` uses many builders, but this PR is only focused on one.\r\n\r\n`TreeBuilderReportReports` is simple:\r\n\r\n- The root nodes are high-level report categories (from the menu)\r\n- The child nodes are low-level report categories (from the menu)\r\n- The grandchild nodes are `MiqReport` records (names from the menu).\r\n\r\n# Before\r\n\r\n- The number of grandchildren is counted from the database.\r\n- Grandchildren are looked up individually.\r\n\r\n# After\r\n\r\n- There are no counts for grandchild since the values come from the menu.\r\n- Grandchildren are looked up using a single query per child (the parent of the grandchildren).\r\n\r\n# Numbers\r\n\r\n|     ms |query | query ms |     rows |`comments`\r\n|    ---:|  ---:|   ---:|      ---:| ---\r\n|  313.5 |   51 | 111.1 |      468 | #1228 applied\r\n|  258.7 |   23 |  86.6 |      440 | #1288 and this applied\r\n| 17.5% | 55% | 22.1% | 6% | diff\r\n\r\nNote: While #1228 and this PR are independent, the numbers seemed more honest if they included that patch in place.\r\n\r\n# Expanded Reports Numbers\r\n\r\n|       ms |query | query ms |     rows |`comments`\r\n|      ---:|  ---:|     ---:|      ---:| ---\r\n|  2,895.3 |  803 | 1,891.5 |      823 | #1228 applied\r\n|  1,408.6 |  444 |   787.3 |      823 | #1228 and this applied\r\n| 51.3% | 45% | 58.4% | 0 | diff\r\n\r\nThese 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.\r\n\r\nPlease 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.\r\n\r\n# High Git Change count\r\n\r\nSince the `@rpt_menu` lookups confused me, I renamed and added many variables\r\n\r\nAlso, 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`).\r\n\r\nI can reduce the lines changed significantly if you prefer that route.\r\n\r\n# Added feature\r\n\r\n@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.\r\n\r\n# Bug\r\n\r\nTree builders work in a few ways:\r\n\r\n1. level by level - e.g.: root returns `[node1, node2]`, level1 returns `[node11, node12]`, level2...\r\n2. complete tree - e.g. root returns `{node1 => {node11 => {}, node12 => {}}, node2 => {}}`\r\n3. partial tree - e.g.: root returns `{node1 => [node11, node12], node2 => []}`, and level2 returns `[node111, node 1112]`\r\n\r\nIt turns out that the 3rd use case did not work properly. I made a change in `tree_builder.rb` to address this issue.\r\n","created_at":"2017-05-04T02:36:03Z","updated_at":"2017-05-04T02:36:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/pulls/1253/commits","review_comments_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/pulls/1253/comments","review_comment_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/issues/1253/comments","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/statuses/2a85d907792cf9598846be594c3c39b2190c9175","head":{"label":"kbrock:tree_reports_r_r","ref":"tree_reports_r_r","sha":"2a85d907792cf9598846be594c3c39b2190c9175","user":{"login":"kbrock","id":1930,"avatar_url":"https://avatars1.githubusercontent.com/u/1930?v=3","gravatar_id":"","url":"https://api.github.com/users/kbrock","html_url":"https://github.com/kbrock","followers_url":"https://api.github.com/users/kbrock/followers","following_url":"https://api.github.com/users/kbrock/following{/other_user}","gists_url":"https://api.github.com/users/kbrock/gists{/gist_id}","starred_url":"https://api.github.com/users/kbrock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbrock/subscriptions","organizations_url":"https://api.github.com/users/kbrock/orgs","repos_url":"https://api.github.com/users/kbrock/repos","events_url":"https://api.github.com/users/kbrock/events{/privacy}","received_events_url":"https://api.github.com/users/kbrock/received_events","type":"User","site_admin":false},"repo":{"id":77964398,"name":"manageiq-ui-classic","full_name":"kbrock/manageiq-ui-classic","owner":{"login":"kbrock","id":1930,"avatar_url":"https://avatars1.githubusercontent.com/u/1930?v=3","gravatar_id":"","url":"https://api.github.com/users/kbrock","html_url":"https://github.com/kbrock","followers_url":"https://api.github.com/users/kbrock/followers","following_url":"https://api.github.com/users/kbrock/following{/other_user}","gists_url":"https://api.github.com/users/kbrock/gists{/gist_id}","starred_url":"https://api.github.com/users/kbrock/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbrock/subscriptions","organizations_url":"https://api.github.com/users/kbrock/orgs","repos_url":"https://api.github.com/users/kbrock/repos","events_url":"https://api.github.com/users/kbrock/events{/privacy}","received_events_url":"https://api.github.com/users/kbrock/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kbrock/manageiq-ui-classic","description":"Classic UI of ManageIQ","fork":true,"url":"https://api.github.com/repos/kbrock/manageiq-ui-classic","forks_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/forks","keys_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/teams","hooks_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/hooks","issue_events_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/issues/events{/number}","events_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/events","assignees_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/assignees{/user}","branches_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/branches{/branch}","tags_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/tags","blobs_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/git/refs{/sha}","trees_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/statuses/{sha}","languages_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/languages","stargazers_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/stargazers","contributors_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/contributors","subscribers_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/subscribers","subscription_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/subscription","commits_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/commits{/sha}","git_commits_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/git/commits{/sha}","comments_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/comments{/number}","issue_comment_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/issues/comments{/number}","contents_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/contents/{+path}","compare_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/merges","archive_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/downloads","issues_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/issues{/number}","pulls_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/pulls{/number}","milestones_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/milestones{/number}","notifications_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/labels{/name}","releases_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/releases{/id}","deployments_url":"https://api.github.com/repos/kbrock/manageiq-ui-classic/deployments","created_at":"2017-01-04T00:14:35Z","updated_at":"2017-01-04T00:14:41Z","pushed_at":"2017-05-04T01:43:29Z","git_url":"git://github.com/kbrock/manageiq-ui-classic.git","ssh_url":"git@github.com:kbrock/manageiq-ui-classic.git","clone_url":"https://github.com/kbrock/manageiq-ui-classic.git","svn_url":"https://github.com/kbrock/manageiq-ui-classic","homepage":null,"size":41873,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ManageIQ:master","ref":"master","sha":"5bb3535192d8666fe05819859a01e87eeca5018a","user":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars3.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"repo":{"id":77085298,"name":"manageiq-ui-classic","full_name":"ManageIQ/manageiq-ui-classic","owner":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars3.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ManageIQ/manageiq-ui-classic","description":"Classic UI of ManageIQ","fork":false,"url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic","forks_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/forks","keys_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/teams","hooks_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/hooks","issue_events_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/issues/events{/number}","events_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/events","assignees_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/assignees{/user}","branches_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/branches{/branch}","tags_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/tags","blobs_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/git/refs{/sha}","trees_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/statuses/{sha}","languages_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/languages","stargazers_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/stargazers","contributors_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/contributors","subscribers_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/subscribers","subscription_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/subscription","commits_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/commits{/sha}","git_commits_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/git/commits{/sha}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/comments{/number}","issue_comment_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/issues/comments{/number}","contents_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/contents/{+path}","compare_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/merges","archive_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/downloads","issues_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/issues{/number}","pulls_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/pulls{/number}","milestones_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/milestones{/number}","notifications_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/labels{/name}","releases_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/releases{/id}","deployments_url":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/deployments","created_at":"2016-12-21T20:53:08Z","updated_at":"2017-04-28T15:50:11Z","pushed_at":"2017-05-04T02:05:40Z","git_url":"git://github.com/ManageIQ/manageiq-ui-classic.git","ssh_url":"git@github.com:ManageIQ/manageiq-ui-classic.git","clone_url":"https://github.com/ManageIQ/manageiq-ui-classic.git","svn_url":"https://github.com/ManageIQ/manageiq-ui-classic","homepage":null,"size":42821,"stargazers_count":12,"watchers_count":12,"language":"Ruby","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":136,"mirror_url":null,"open_issues_count":185,"forks":136,"open_issues":185,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/pulls/1253"},"html":{"href":"https://github.com/ManageIQ/manageiq-ui-classic/pull/1253"},"issue":{"href":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/issues/1253"},"comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/issues/1253/comments"},"review_comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/pulls/1253/comments"},"review_comment":{"href":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/pulls/1253/commits"},"statuses":{"href":"https://api.github.com/repos/ManageIQ/manageiq-ui-classic/statuses/2a85d907792cf9598846be594c3c39b2190c9175"}},"merged":false,"mergeable":null,"rebaseable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"maintainer_can_modify":true,"commits":2,"additions":29,"deletions":35,"changed_files":2}}
{"actor":{"display_login":"kbrock"}}