From ff21ebc76c3b036038372ef894a4b77dd7481aef Mon Sep 17 00:00:00 2001 From: Mark Fletcher Date: Wed, 29 May 2019 14:32:43 +0100 Subject: [PATCH] Customer Bugs Dashboard --- .../application/customer_bugs.coffee | 45 +++++++++++++++++++ .../javascripts/application/teams.coffee | 20 +++------ app/views/groups/customer_bugs.html.haml | 2 + app/views/groups/show.html.haml | 1 + app/views/projects/customer_bugs.html.haml | 1 + app/views/projects/show.html.haml | 1 + app/views/shared/_customer_bugs.html.haml | 40 +++++++++++++++++ config/routes.rb | 2 + lib/gitlab_insights.rb | 4 +- 9 files changed, 101 insertions(+), 15 deletions(-) create mode 100644 app/assets/javascripts/application/customer_bugs.coffee create mode 100644 app/views/groups/customer_bugs.html.haml create mode 100644 app/views/projects/customer_bugs.html.haml create mode 100644 app/views/shared/_customer_bugs.html.haml diff --git a/app/assets/javascripts/application/customer_bugs.coffee b/app/assets/javascripts/application/customer_bugs.coffee new file mode 100644 index 0000000..d3025ac --- /dev/null +++ b/app/assets/javascripts/application/customer_bugs.coffee @@ -0,0 +1,45 @@ +CustomerBugsNumber = (element) -> + query = @queries.ScopedQuery(@queries.IssuablesPerLabelPercentageQuery( + 'Open', + @query_strings.Bugs, + '["customer","customer+"]', + @query_strings.IssuesScope + )) + @charts.BigNumberPercentage(element, query.query_string, query.view_string) + +CustomerBugsPie = (element) -> + query = @queries.ScopedQuery(@queries.IssuablesPerLabelQuery( + 'Open', + @query_strings.Bugs, + '["customer","customer+"]', + @query_strings.IssuesScope + )) + @charts.PieChart(element, query.query_string, query.view_string) + +CustomerBugsCreatedPerMonthChart = (element) -> + query = @queries.ScopedQuery(@queries.IssuablesCreatedPerMonthQuery( + 'Open', + '["bug", "customer"]', + @query_strings.Teams, + @query_strings.IssuesScope + )) + @charts.StackedBarChart(element, query.query_string, query.view_string) + +CustomerPlusBugsCreatedPerMonthChart = (element) -> + query = @queries.ScopedQuery(@queries.IssuablesCreatedPerMonthQuery( + 'Open', + '["bug", "customer+"]', + @query_strings.Teams, + @query_strings.IssuesScope + )) + @charts.StackedBarChart(element, query.query_string, query.view_string) + +$(document).ready () -> + if document.getElementById('customer-bugs-number') + CustomerBugsNumber(document.getElementById('customer-bugs-number')) + if document.getElementById('customer-bugs-pie') + CustomerBugsPie(document.getElementById('customer-bugs-pie')) + if document.getElementById('customer-bugs-created-per-month') + CustomerBugsCreatedPerMonthChart(document.getElementById('customer-bugs-created-per-month')) + if document.getElementById('customer-plus-bugs-created-per-month') + CustomerPlusBugsCreatedPerMonthChart(document.getElementById('customer-plus-bugs-created-per-month')) diff --git a/app/assets/javascripts/application/teams.coffee b/app/assets/javascripts/application/teams.coffee index 991d437..1b8f12d 100644 --- a/app/assets/javascripts/application/teams.coffee +++ b/app/assets/javascripts/application/teams.coffee @@ -2,27 +2,19 @@ team_label_query_segment = (label_json) -> label_array = if label_json then JSON.parse(label_json) else [] label_array.push($('#team-label').val()) JSON.stringify(label_array) -TeamBugsSeverityNumber = (element) -> +CustomerBugsNumber = (element) -> query = @queries.ScopedQuery(@queries.IssuablesPerLabelPercentageQuery( 'Open', - team_label_query_segment(@query_strings.Bugs), - @query_strings.Severities, + @query_strings.Bugs, + "['customer','customer+']", @query_strings.IssuesScope )) @charts.BigNumberPercentage(element, query.query_string, query.view_string) -TeamBugsPriorityNumber = (element) -> - query = @queries.ScopedQuery(@queries.IssuablesPerLabelPercentageQuery( - 'Open', - team_label_query_segment(@query_strings.Bugs), - @query_strings.Priorities, - @query_strings.IssuesScope - )) - @charts.BigNumberPercentage(element, query.query_string, query.view_string) -TeamBugsSeverityPie = (element) -> +CustomerBugsPie = (element) -> query = @queries.ScopedQuery(@queries.IssuablesPerLabelQuery( 'Open', - team_label_query_segment(@query_strings.Bugs), - @query_strings.Severities, + @query_strings.Bugs, + "['customer','customer+']", @query_strings.IssuesScope )) @charts.PieChart(element, query.query_string, query.view_string) diff --git a/app/views/groups/customer_bugs.html.haml b/app/views/groups/customer_bugs.html.haml new file mode 100644 index 0000000..379af90 --- /dev/null +++ b/app/views/groups/customer_bugs.html.haml @@ -0,0 +1,2 @@ += render partial: 'shared/customer_bugs', locals: { source: @group } += render partial: 'shared/project_level_links', locals: { group: @group, name: 'customer bugs', link: method(:group_project_customer_bugs_path) } diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index 4d9a695..593715c 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -35,6 +35,7 @@ = link_to 'Bugs By Severity', group_bugs_by_severity_path(@group.path), class: 'list-group-item' = link_to 'Bugs By Priority', group_bugs_by_priority_path(@group.path), class: 'list-group-item' = link_to 'Bug Classification', group_bug_classification_path(@group.path), class: 'list-group-item' + = link_to 'Customer Bugs', group_customer_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 'EXPERIMENTAL - Merge Requests by State', group_mrs_by_state_path(@group.path), class: 'list-group-item' diff --git a/app/views/projects/customer_bugs.html.haml b/app/views/projects/customer_bugs.html.haml new file mode 100644 index 0000000..636868b --- /dev/null +++ b/app/views/projects/customer_bugs.html.haml @@ -0,0 +1 @@ += render partial: 'shared/customer_bugs', locals: { source: @project } diff --git a/app/views/projects/show.html.haml b/app/views/projects/show.html.haml index e21449f..e310f0a 100644 --- a/app/views/projects/show.html.haml +++ b/app/views/projects/show.html.haml @@ -33,6 +33,7 @@ = link_to 'Bugs By Severity', group_project_bugs_by_severity_path(@group.path, @project.path), class: 'list-group-item' = link_to 'Bugs By Priority', group_project_bugs_by_priority_path(@group.path, @project.path), class: 'list-group-item' = link_to 'Bug Classification', group_project_bug_classification_path(@group.path, @project.path), class: 'list-group-item' + = link_to 'Customer Bugs', group_project_customer_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 'EXPERIMENTAL - Merge Requests by State', group_project_mrs_by_state_path(@group.path, @project.path), class: 'list-group-item' diff --git a/app/views/shared/_customer_bugs.html.haml b/app/views/shared/_customer_bugs.html.haml new file mode 100644 index 0000000..6c0317f --- /dev/null +++ b/app/views/shared/_customer_bugs.html.haml @@ -0,0 +1,40 @@ +.container + .page-header + %h1.page-title= "Dashboard: #{source.path}" + .page-header + %h2.page-title Customer Bugs + .row.row-cards + .col-6.col-sm-4.col-lg-2 + .card + .card-body.p-3.text-center + #customer-bugs-number + .total.h1.m-0 0 + .text-muted.mb-4 Percentage Bugs Customer + .col-4 + .card + .card-header + %h3.card-title Open Bugs by Customer Label + .card-body + %canvas#customer-bugs-pie + .row.row-cards + .col-lg-12 + .card + .card-header + %h3.card-title Customer Bugs Created Per Month + .card-body + %canvas#customer-bugs-created-per-month + .card-body + %div + %div.text-wrap + %p Displays number of remaining, open, customer bugs created over time grouped by Team + .row.row-cards + .col-lg-12 + .card + .card-header + %h3.card-title Customer+ Bugs Created Per Month + .card-body + %canvas#customer-plus-bugs-created-per-month + .card-body + %div + %div.text-wrap + %p Displays number of remaining, open, customer+ bugs created over time grouped by Team diff --git a/config/routes.rb b/config/routes.rb index aafa332..0385d3c 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,7 @@ Rails.application.routes.draw do get :bugs_by_team get :bugs_by_severity get :bugs_by_priority + get :customer_bugs get :feature_proposals_by_team get :issues_by_state get :mrs_by_state @@ -21,6 +22,7 @@ Rails.application.routes.draw do get :bugs_by_team get :bugs_by_severity get :bugs_by_priority + get :customer_bugs get :feature_proposals_by_team get :issues_by_state get :mrs_by_state diff --git a/lib/gitlab_insights.rb b/lib/gitlab_insights.rb index d0264d3..2f1ced9 100644 --- a/lib/gitlab_insights.rb +++ b/lib/gitlab_insights.rb @@ -32,6 +32,7 @@ module GitlabInsights COMMUNITY_CONTRIBUTION_COLOR = "#a8d695" DEFAULT_COLOR = "#428bca" LINE_COLOR = COLOR_SCHEME[:red] + CUSTOMER_COLOR = "#ad4363" STATIC_COLOR_MAP = { UNCATEGORIZED => UNCATEGORIZED_COLOR, @@ -64,6 +65,7 @@ module GitlabInsights "Geo" => COLOR_SCHEME[:lavender], "Quality" => COLOR_SCHEME[:maroon], "gitter" => COLOR_SCHEME[:brown], - "frontend" => COLOR_SCHEME[:mint] + "frontend" => COLOR_SCHEME[:mint], + "customer" => CUSTOMER_COLOR } end -- GitLab