From dfed74a1728724a0b75b21443865070e46c5e795 Mon Sep 17 00:00:00 2001 From: Mark Fletcher Date: Thu, 14 Jun 2018 15:41:02 +0100 Subject: [PATCH 1/2] Clarify issue status for graphs --- app/views/projects/bugs_by_severity.html.haml | 6 +++--- app/views/projects/bugs_by_team.html.haml | 6 +++--- app/views/projects/feature_proposals_by_team.html.haml | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/views/projects/bugs_by_severity.html.haml b/app/views/projects/bugs_by_severity.html.haml index 6ed031a..c520dd6 100644 --- a/app/views/projects/bugs_by_severity.html.haml +++ b/app/views/projects/bugs_by_severity.html.haml @@ -7,17 +7,17 @@ .col-lg-12 .card .card-header - %h3.card-title Cumulative Open bugs by Severity + %h3.card-title Cumulative Bugs Created Per Month Per Severity (open state) %canvas#cumulative-bugs-created-severity-month .row.row-cards .col-lg-12 .card .card-header - %h3.card-title Open bugs by Severity + %h3.card-title Bugs created Per Month Per Severity (open state) %canvas#bugs-created-severity-month .row.row-cards .col-lg-12 .card .card-header - %h3.card-title Closed bugs by Severity + %h3.card-title Bugs closed Per Month Per Severity %canvas#bugs-closed-severity-month diff --git a/app/views/projects/bugs_by_team.html.haml b/app/views/projects/bugs_by_team.html.haml index 00bfa50..e7ccf98 100644 --- a/app/views/projects/bugs_by_team.html.haml +++ b/app/views/projects/bugs_by_team.html.haml @@ -7,13 +7,13 @@ .col-lg-12 .card .card-header - %h3.card-title Cumulative Bugs Created Per Month Per Team + %h3.card-title Cumulative Bugs Created Per Month Per Team (open state) %canvas#cumulative-bugs-created-per-month .row.row-cards .col-lg-12 .card .card-header - %h3.card-title Bugs Created Per Month Per Team + %h3.card-title Bugs Created Per Month Per Team (open state) %canvas#bugs-created-per-month .row.row-cards .col-lg-12 @@ -25,7 +25,7 @@ .col-lg-12 .card .card-header - %h3.card-title Bugs Created Per Day Per Team + %h3.card-title Bugs Created Per Day Per Team (open state) %canvas#bugs-created-per-day .row.row-cards .col-lg-12 diff --git a/app/views/projects/feature_proposals_by_team.html.haml b/app/views/projects/feature_proposals_by_team.html.haml index 646656e..174921c 100644 --- a/app/views/projects/feature_proposals_by_team.html.haml +++ b/app/views/projects/feature_proposals_by_team.html.haml @@ -7,7 +7,7 @@ .col-lg-12 .card .card-header - %h3.card-title Feature Proposal Created Per Month Per Team + %h3.card-title Feature Proposal Created Per Month Per Team (open state) %canvas#proposals-created-per-month .row.row-cards .col-lg-12 -- GitLab From d479b4638b0bd598375783d5fe428e004dca0c5f Mon Sep 17 00:00:00 2001 From: Mark Fletcher Date: Thu, 14 Jun 2018 16:28:51 +0100 Subject: [PATCH 2/2] New graphs that do not filter on state --- .../javascripts/bugs_by_severity.coffee | 122 ++++++++++++++++- app/assets/javascripts/bugs_by_team.coffee | 124 +++++++++++++++++- app/views/projects/bugs_by_severity.html.haml | 14 +- app/views/projects/bugs_by_team.html.haml | 16 ++- .../periodic_issues_per_label_finder.rb | 2 +- 5 files changed, 269 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/bugs_by_severity.coffee b/app/assets/javascripts/bugs_by_severity.coffee index e265b5f..b42c7b7 100644 --- a/app/assets/javascripts/bugs_by_severity.coffee +++ b/app/assets/javascripts/bugs_by_severity.coffee @@ -1,3 +1,60 @@ +CumulativeAllBugsCreatedBySeverityPerMonthChart = (element) -> + build_request_data = (query_string) -> + { + query: query_string + } + + build_labels = (data) -> + data['data']['project']['cumulative_issues_created_per_month']['titles'] + + build_datasets = (data) -> + data['data']['project']['cumulative_issues_created_per_month']['series'] + + query_string = ' + { + project(group_path:"' + $('#group-path').val() + '", project_path:"' + $('#project-path').val() + '") { + cumulative_issues_created_per_month(filter_labels:["bug"], collection_labels: ["S1", "S2", "S3", "S4"]) { + titles + series { + label + data + backgroundColor + } + } + } + } + ' + + config = { + type: 'bar', + options: { + scales: { + xAxes: [{ + stacked: true + }] + yAxes: [{ + stacked: true + }] + } + } + } + + $.ajax({ + url: '/graphql', + method: 'POST', + dataType: 'json', + data: build_request_data(query_string), + success: (data) -> + config['data'] = { + labels: build_labels(data), + datasets: build_datasets(data) + } + async: false + }) + + context = element.getContext('2d') + chart = new Chart(context, config) + CumulativeBugsCreatedBySeverityPerMonthChart = (element) -> build_request_data = (query_string) -> { @@ -112,6 +169,63 @@ BugsCreatedBySeverityPerMonthChart = (element) -> context = element.getContext('2d') chart = new Chart(context, config) +AllBugsCreatedBySeverityPerMonthChart = (element) -> + build_request_data = (query_string) -> + { + query: query_string + } + + build_labels = (data) -> + data['data']['project']['issues_created_per_month']['titles'] + + build_datasets = (data) -> + data['data']['project']['issues_created_per_month']['series'] + + query_string = ' + { + project(group_path:"' + $('#group-path').val() + '", project_path:"' + $('#project-path').val() + '") { + issues_created_per_month(filter_labels:["bug"], collection_labels: ["S1", "S2", "S3", "S4"]) { + titles + series { + label + data + backgroundColor + } + } + } + } + ' + + config = { + type: 'bar', + options: { + scales: { + xAxes: [{ + stacked: true + }] + yAxes: [{ + stacked: true + }] + } + } + } + + $.ajax({ + url: '/graphql', + method: 'POST', + dataType: 'json', + data: build_request_data(query_string), + success: (data) -> + config['data'] = { + labels: build_labels(data), + datasets: build_datasets(data) + } + async: false + }) + + context = element.getContext('2d') + chart = new Chart(context, config) + BugsClosedBySeverityPerMonthChart = (element) -> build_request_data = (query_string) -> { @@ -170,8 +284,12 @@ BugsClosedBySeverityPerMonthChart = (element) -> chart = new Chart(context, config) $(document).ready () -> - if document.getElementById('cumulative-bugs-created-severity-month') - CumulativeBugsCreatedBySeverityPerMonthChart(document.getElementById('cumulative-bugs-created-severity-month')) + if document.getElementById('cumulative-all-bugs-severity-month') + CumulativeAllBugsCreatedBySeverityPerMonthChart(document.getElementById('cumulative-all-bugs-severity-month')) + if document.getElementById('cumulative-open-bugs-created-severity-month') + CumulativeBugsCreatedBySeverityPerMonthChart(document.getElementById('cumulative-open-bugs-created-severity-month')) + if document.getElementById('all-bugs-created-severity-month') + AllBugsCreatedBySeverityPerMonthChart(document.getElementById('all-bugs-created-severity-month')) if document.getElementById('bugs-created-severity-month') BugsCreatedBySeverityPerMonthChart(document.getElementById('bugs-created-severity-month')) if document.getElementById('bugs-closed-severity-month') diff --git a/app/assets/javascripts/bugs_by_team.coffee b/app/assets/javascripts/bugs_by_team.coffee index d912108..955b6fa 100644 --- a/app/assets/javascripts/bugs_by_team.coffee +++ b/app/assets/javascripts/bugs_by_team.coffee @@ -1,4 +1,61 @@ -CumulativeBugsCreatedPerMonthChart = (element) -> +CumulativeAllBugsCreatedPerMonthChart = (element) -> + build_request_data = (query_string) -> + { + query: query_string + } + + build_labels = (data) -> + data['data']['project']['cumulative_issues_created_per_month']['titles'] + + build_datasets = (data) -> + data['data']['project']['cumulative_issues_created_per_month']['series'] + + query_string = ' + { + project(group_path:"' + $('#group-path').val() + '", project_path:"' + $('#project-path').val() + '") { + cumulative_issues_created_per_month(filter_labels:["bug"], collection_labels: ["Discussion", "Platform", "CI/CD", "Gitaly", "Distribution", "Monitoring", "Geo", "frontend"]) { + titles + series { + label + data + backgroundColor + } + } + } + } + ' + + config = { + type: 'bar', + options: { + scales: { + xAxes: [{ + stacked: true + }] + yAxes: [{ + stacked: true + }] + } + } + } + + $.ajax({ + url: '/graphql', + method: 'POST', + dataType: 'json', + data: build_request_data(query_string), + success: (data) -> + config['data'] = { + labels: build_labels(data), + datasets: build_datasets(data) + } + async: false + }) + + context = element.getContext('2d') + chart = new Chart(context, config) + +CumulativeOpenBugsCreatedPerMonthChart = (element) -> build_request_data = (query_string) -> { query: query_string @@ -112,6 +169,63 @@ BugsCreatedPerMonthChart = (element) -> context = element.getContext('2d') chart = new Chart(context, config) +AllBugsCreatedPerMonthChart = (element) -> + build_request_data = (query_string) -> + { + query: query_string + } + + build_labels = (data) -> + data['data']['project']['issues_created_per_month']['titles'] + + build_datasets = (data) -> + data['data']['project']['issues_created_per_month']['series'] + + query_string = ' + { + project(group_path:"' + $('#group-path').val() + '", project_path:"' + $('#project-path').val() + '") { + issues_created_per_month(filter_labels:["bug"], collection_labels: ["Discussion", "Platform", "CI/CD", "Gitaly", "Distribution", "Monitoring", "Geo", "frontend"]) { + titles + series { + label + data + backgroundColor + } + } + } + } + ' + + config = { + type: 'bar', + options: { + scales: { + xAxes: [{ + stacked: true + }] + yAxes: [{ + stacked: true + }] + } + } + } + + $.ajax({ + url: '/graphql', + method: 'POST', + dataType: 'json', + data: build_request_data(query_string), + success: (data) -> + config['data'] = { + labels: build_labels(data), + datasets: build_datasets(data) + } + async: false + }) + + context = element.getContext('2d') + chart = new Chart(context, config) + BugsCreatedPerDayChart = (element) -> build_request_data = (query_string) -> { @@ -284,8 +398,12 @@ BugsClosedPerDayChart = (element) -> chart = new Chart(context, config) $(document).ready () -> - if document.getElementById('cumulative-bugs-created-per-month') - CumulativeBugsCreatedPerMonthChart(document.getElementById('cumulative-bugs-created-per-month')) + if document.getElementById('cumulative-all-bugs-created-per-month') + CumulativeAllBugsCreatedPerMonthChart(document.getElementById('cumulative-all-bugs-created-per-month')) + if document.getElementById('cumulative-open-bugs-created-per-month') + CumulativeOpenBugsCreatedPerMonthChart(document.getElementById('cumulative-open-bugs-created-per-month')) + if document.getElementById('all-bugs-created-per-month') + AllBugsCreatedPerMonthChart(document.getElementById('all-bugs-created-per-month')) if document.getElementById('bugs-created-per-month') BugsCreatedPerMonthChart(document.getElementById('bugs-created-per-month')) if document.getElementById('bugs-created-per-day') diff --git a/app/views/projects/bugs_by_severity.html.haml b/app/views/projects/bugs_by_severity.html.haml index c520dd6..814d159 100644 --- a/app/views/projects/bugs_by_severity.html.haml +++ b/app/views/projects/bugs_by_severity.html.haml @@ -3,12 +3,24 @@ %h1.page-title= "Project Dashboard: #{@project.path}" .page-header %h2.page-title Bugs By Severity + .row.row-cards + .col-lg-12 + .card + .card-header + %h3.card-title Cumulative Bugs Created Per Month Per Severity (open and closed) + %canvas#cumulative-all-bugs-severity-month .row.row-cards .col-lg-12 .card .card-header %h3.card-title Cumulative Bugs Created Per Month Per Severity (open state) - %canvas#cumulative-bugs-created-severity-month + %canvas#cumulative-open-bugs-created-severity-month + .row.row-cards + .col-lg-12 + .card + .card-header + %h3.card-title Bugs created Per Month Per Severity (open and closed) + %canvas#all-bugs-created-severity-month .row.row-cards .col-lg-12 .card diff --git a/app/views/projects/bugs_by_team.html.haml b/app/views/projects/bugs_by_team.html.haml index e7ccf98..0b2d250 100644 --- a/app/views/projects/bugs_by_team.html.haml +++ b/app/views/projects/bugs_by_team.html.haml @@ -7,8 +7,20 @@ .col-lg-12 .card .card-header - %h3.card-title Cumulative Bugs Created Per Month Per Team (open state) - %canvas#cumulative-bugs-created-per-month + %h3.card-title Cumulative Bugs Created Per Month Per Team (open and closed) + %canvas#cumulative-all-bugs-created-per-month + .row.row-cards + .col-lg-12 + .card + .card-header + %h3.card-title Cumulative Open Bugs Created Per Month Per Team (open state) + %canvas#cumulative-open-bugs-created-per-month + .row.row-cards + .col-lg-12 + .card + .card-header + %h3.card-title Bugs Created Per Month Per Team (open and closed) + %canvas#all-bugs-created-per-month .row.row-cards .col-lg-12 .card diff --git a/lib/gitlab_insights/finders/periodic_issues_per_label_finder.rb b/lib/gitlab_insights/finders/periodic_issues_per_label_finder.rb index 31be1d7..06bf4cc 100644 --- a/lib/gitlab_insights/finders/periodic_issues_per_label_finder.rb +++ b/lib/gitlab_insights/finders/periodic_issues_per_label_finder.rb @@ -18,7 +18,7 @@ module GitlabInsights def find(opts) Rails.cache.fetch({project: project, opts: opts, field: field, period_type: period_normalizer}, expires_in: 3.hours) do results = project.issues - results = results.where(state: opts[:state]) + results = results.where(state: opts[:state]) if opts[:state] results = results.all(labels: opts[:filter_labels]) results = results.order(field => :asc) # issues will need to be closed for `closed_at` to be populated -- GitLab