From 9bbe4d68a2e3dce6805a9ace40ec710047fcf347 Mon Sep 17 00:00:00 2001 From: Mark Fletcher Date: Mon, 17 Jun 2019 11:23:42 +0100 Subject: [PATCH] Dashboard for Issue categories --- .../application/issues_by_category.coffee | 19 +++++++++++++ .../javascripts/application/queries.coffee | 26 ++++++++++++++++++ .../application/query_strings.coffee | 1 + app/views/groups/issues_by_category.html.haml | 2 ++ app/views/groups/show.html.haml | 1 + .../projects/issues_by_category.html.haml | 1 + app/views/projects/show.html.haml | 1 + .../shared/_issues_by_category.html.haml | 27 +++++++++++++++++++ config/routes.rb | 2 ++ lib/gitlab_insights.rb | 4 ++- 10 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 app/assets/javascripts/application/issues_by_category.coffee create mode 100644 app/views/groups/issues_by_category.html.haml create mode 100644 app/views/projects/issues_by_category.html.haml create mode 100644 app/views/shared/_issues_by_category.html.haml diff --git a/app/assets/javascripts/application/issues_by_category.coffee b/app/assets/javascripts/application/issues_by_category.coffee new file mode 100644 index 0000000..c13e5c8 --- /dev/null +++ b/app/assets/javascripts/application/issues_by_category.coffee @@ -0,0 +1,19 @@ +IssuesByCategoryPerMonthChart = (element) -> + query = @queries.ScopedQuery(@queries.EveryIssuablesCreatedPerMonthQuery( + @query_strings.IssueCategories, + @query_strings.IssuesScope + )) + @charts.StackedBarChart(element, query.query_string, query.view_string) +OpenIssuesByCategoryPerMonthChart = (element) -> + query = @queries.ScopedQuery(@queries.UnfilteredIssuablesCreatedPerMonthQuery( + 'Open', + @query_strings.IssueCategories, + @query_strings.IssuesScope + )) + @charts.StackedBarChart(element, query.query_string, query.view_string) + +$(document).ready () -> + if document.getElementById('issues-by-category') + IssuesByCategoryPerMonthChart(document.getElementById('issues-by-category')) + if document.getElementById('open-issues-by-category') + OpenIssuesByCategoryPerMonthChart(document.getElementById('open-issues-by-category')) diff --git a/app/assets/javascripts/application/queries.coffee b/app/assets/javascripts/application/queries.coffee index c1895ad..fce4a0e 100644 --- a/app/assets/javascripts/application/queries.coffee +++ b/app/assets/javascripts/application/queries.coffee @@ -52,6 +52,32 @@ project_query = (group_path, project_path, view_string, inner_query) -> } } ' + UnfilteredIssuablesCreatedPerMonthQuery: (state_string, collection_labels_string, issuable_scope) -> + view_string: 'issuables_created_per_month', + query_string: ' + issuables_created_per_month(state:' + state_string + ', collection_labels: ' + collection_labels_string + ', issuable_scope: ' + issuable_scope + ') { + labels + datasets { + label + data + borderColor + backgroundColor + } + } + ' + EveryIssuablesCreatedPerMonthQuery: (collection_labels_string, issuable_scope) -> + view_string: 'issuables_created_per_month', + query_string: ' + issuables_created_per_month(collection_labels: ' + collection_labels_string + ', issuable_scope: ' + issuable_scope + ') { + labels + datasets { + label + data + borderColor + backgroundColor + } + } + ' IssuablesClosedPerMonthQuery: (state_string, filter_labels_string, collection_labels_string, issuable_scope) -> view_string: 'issuables_closed_per_month', query_string: ' diff --git a/app/assets/javascripts/application/query_strings.coffee b/app/assets/javascripts/application/query_strings.coffee index 465c2dc..425afad 100644 --- a/app/assets/javascripts/application/query_strings.coffee +++ b/app/assets/javascripts/application/query_strings.coffee @@ -13,5 +13,6 @@ MissedDeliverable: '["missed-deliverable"]', MissedDeliverableMilestones: '["missed:11.0","missed:11.1","missed:11.2","missed:11.3","missed:11.4","missed:11.5", "missed:11.6", "missed:11.7", "missed:11.8", "missed:11.9", "missed:11.10", "missed:11.11", "missed:12.0"]' MergeRequestCategories: '["Community contribution","security","bug","feature","backstage"]' + IssueCategories: '["bug","feature","support request","backstage"]' TeamMRWeeks: 12 TeamMRMonths: 24 diff --git a/app/views/groups/issues_by_category.html.haml b/app/views/groups/issues_by_category.html.haml new file mode 100644 index 0000000..7b479b3 --- /dev/null +++ b/app/views/groups/issues_by_category.html.haml @@ -0,0 +1,2 @@ += render partial: 'shared/issues_by_category', locals: { source: @group } += render partial: 'shared/project_level_links', locals: { group: @group, name: 'issues by category', link: method(:group_project_issues_by_category_path) } diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index 33d1a32..ad7f353 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -26,6 +26,7 @@ = link_to 'Time to Close Bugs', group_time_to_close_bugs_path(@group.path), class: 'list-group-item' = link_to 'Feature Proposals by Team', group_feature_proposals_by_team_path(@group.path), class: 'list-group-item' = link_to 'Issues by State', group_issues_by_state_path(@group.path), class: 'list-group-item' + = link_to 'Issues by Category', group_issues_by_category_path(@group.path), class: 'list-group-item' = link_to 'EXPERIMENTAL - Merge Requests by State', group_mrs_by_state_path(@group.path), class: 'list-group-item' = link_to 'Regressions', group_regressions_path(@group.path), class: 'list-group-item' = link_to 'Missed Deliverables', group_missed_deliverables_path(@group.path), class: 'list-group-item' diff --git a/app/views/projects/issues_by_category.html.haml b/app/views/projects/issues_by_category.html.haml new file mode 100644 index 0000000..d270236 --- /dev/null +++ b/app/views/projects/issues_by_category.html.haml @@ -0,0 +1 @@ += render partial: 'shared/issues_by_category', locals: { source: @project } diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index bf50cc8..fa24158 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -24,6 +24,7 @@ = link_to 'Time to Close Bugs', group_project_time_to_close_bugs_path(@group.path, @project.path), class: 'list-group-item' = link_to 'Feature Proposals by Team', group_project_feature_proposals_by_team_path(@group.path, @project.path), class: 'list-group-item' = link_to 'Issues by State', group_project_issues_by_state_path(@group.path, @project.path), class: 'list-group-item' + = link_to 'Issues by Category', group_project_issues_by_category_path(@group.path, @project.path), class: 'list-group-item' = link_to 'EXPERIMENTAL - Merge Requests by State', group_project_mrs_by_state_path(@group.path, @project.path), class: 'list-group-item' = link_to 'Regressions', group_project_regressions_path(@group.path, @project.path), class: 'list-group-item' = link_to 'Missed Deliverables', group_project_missed_deliverables_path(@group.path, @project.path), class: 'list-group-item' diff --git a/app/views/shared/_issues_by_category.html.haml b/app/views/shared/_issues_by_category.html.haml new file mode 100644 index 0000000..5987225 --- /dev/null +++ b/app/views/shared/_issues_by_category.html.haml @@ -0,0 +1,27 @@ +.container + .page-header + %h1.page-title= "Dashboard: #{source.path}" + .page-header + %h2.page-title Issues by Category Per Month + .row.row-cards + .col-lg-12 + .card + .card-header + %h3.card-title All Issues by Category + .card-body + %canvas#issues-by-category + .card-body + %div + %div.text-wrap + %p Issues in all states (Open/Closed) split by main type labels, `bug`, `feature`, `support request`, `backstage` + .row.row-cards + .col-lg-12 + .card + .card-header + %h3.card-title Open Issues by Category + .card-body + %canvas#open-issues-by-category + .card-body + %div + %div.text-wrap + %p Issues that remain open split by main type labels, `bug`, `feature`, `support request`, `backstage` diff --git a/config/routes.rb b/config/routes.rb index 7ee4a53..26f5aa1 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -7,6 +7,7 @@ Rails.application.routes.draw do get :bugs_past_slo get :feature_proposals_by_team get :issues_by_state + get :issues_by_category get :mrs_by_state get :regressions get :missed_deliverables @@ -28,6 +29,7 @@ Rails.application.routes.draw do get :bugs_past_slo get :feature_proposals_by_team get :issues_by_state + get :issues_by_category get :mrs_by_state get :regressions get :missed_deliverables diff --git a/lib/gitlab_insights.rb b/lib/gitlab_insights.rb index 70593b5..3e235c5 100644 --- a/lib/gitlab_insights.rb +++ b/lib/gitlab_insights.rb @@ -31,6 +31,7 @@ module GitlabInsights BUG_COLOR = "#ff0000" SECURITY_COLOR = "#d9534f" COMMUNITY_CONTRIBUTION_COLOR = "#a8d695" + SUPPORT_COLOR = "#ad8d43" DEFAULT_COLOR = "#428bca" LINE_COLOR = COLOR_SCHEME[:red] @@ -54,6 +55,7 @@ module GitlabInsights "security" => SECURITY_COLOR, "Community contribution" => COMMUNITY_CONTRIBUTION_COLOR, "backstage" => DEFAULT_COLOR, + 'support request' => SUPPORT_COLOR, "Manage" => COLOR_SCHEME[:orange], "Plan" => COLOR_SCHEME[:green], "Create" => COLOR_SCHEME[:yellow], @@ -74,7 +76,7 @@ module GitlabInsights 'avg' => AVG_COLOR, '85' => PERCENTILE_85_COLOR, '95' => PERCENTILE_95_COLOR, - 'closed' => CLOSED_ISSUES_COLOR + 'closed' => CLOSED_ISSUES_COLOR, } TEAMS = [ -- GitLab