Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
7cf73994
Commit
7cf73994
authored
Oct 28, 2019
by
Pavel Shutsin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix productivity analytics listing with multiple labels
parent
c53477fa
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
223 additions
and
156 deletions
+223
-156
changelogs/unreleased/33182-fix-productivity-analytics-multiple-labels-bug.yml
.../33182-fix-productivity-analytics-multiple-labels-bug.yml
+5
-0
ee/app/models/productivity_analytics.rb
ee/app/models/productivity_analytics.rb
+16
-8
ee/spec/models/productivity_analytics_spec.rb
ee/spec/models/productivity_analytics_spec.rb
+202
-148
No files found.
changelogs/unreleased/33182-fix-productivity-analytics-multiple-labels-bug.yml
0 → 100644
View file @
7cf73994
---
title
:
Fix productivity analytics listing with multiple labels
merge_request
:
33182
author
:
type
:
fixed
ee/app/models/productivity_analytics.rb
View file @
7cf73994
...
...
@@ -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
ee/spec/models/productivity_analytics_spec.rb
View file @
7cf73994
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment