Commit c751939a authored by Andreas Brandl's avatar Andreas Brandl

Merge branch '33182-fix-productivity-analytics-multiple-labels-bug' into 'master'

Fix productivity analytics listing with multiple labels

Closes #33182

See merge request gitlab-org/gitlab!19238
parents b7fd0f21 14ecaff4
---
title: Fix productivity analytics listing with multiple labels
merge_request: 33182
author:
type: fixed
......@@ -43,28 +43,36 @@ class ProductivityAnalytics
end
columns.unshift(MergeRequest.arel_table[Arel.star])
mrs = merge_requests.select(columns)
mrs = mrs.reorder(custom_sorting) if custom_sorting
mrs
MergeRequest.joins(:metrics).select(columns).where(id: merge_requests).order(sorting)
end
private
def histogram_query(column)
merge_requests.except(:select).select("#{column} as metric, count(*) as mr_count").group(column).reorder(nil)
MergeRequest::Metrics.joins(:merge_request)
.where(merge_request_id: merge_requests)
.select("#{column} as metric, count(*) as mr_count")
.group(column)
end
def scatterplot_query(column)
merge_requests.except(:select).select("#{column} as metric, merge_requests.id, merge_request_metrics.merged_at").reorder("merge_request_metrics.merged_at ASC")
merge_requests
.except(:select)
.select("#{column} as metric, merge_requests.id, merge_request_metrics.merged_at")
.reorder("merge_request_metrics.merged_at ASC")
end
def custom_sorting
return unless sort
def sorting
return default_sorting unless sort
column, direction = sort.split(/_(asc|desc)$/i)
return unless column.in?(METRIC_TYPES)
return default_sorting unless column.in?(METRIC_TYPES)
Arel.sql("#{column} #{direction}")
end
def default_sorting
{ id: :desc }
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment