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
6234d035
Commit
6234d035
authored
Aug 03, 2018
by
Jan Provaznik
Committed by
Yorick Peterse
Aug 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Rails5] Fix GROUP BY for mysql
parent
b5cc8c42
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
ee/app/models/burndown.rb
ee/app/models/burndown.rb
+14
-5
No files found.
ee/app/models/burndown.rb
View file @
6234d035
...
...
@@ -97,18 +97,27 @@ class Burndown
::
Issue
.
select
(
"*"
)
.
from
(
internal_clause
.
select
(
'DISTINCT ON (issues.id) issues.id, issues.state, issues.weight, e.created_at AS closed_at'
))
.
order
(
'closed_at ASC'
)
.
pluck
(
'closed_at, weight, state'
)
else
# In rails 5 mysql's `only_full_group_by` option is enabled by default,
# this means that `GROUP` clause must include all columns used in `SELECT`
# clause. Adding all columns to `GROUP` means that we have now
# duplicates (by issue ID) in records. To get rid of these, we unify them
# on ruby side by issue id. Finally we drop the issue id attribute from records
# because this is not accepted when creating Issue object.
::
Issue
.
select
(
"*"
)
.
from
(
internal_clause
.
select
(
'issues.id, issues.state, issues.weight, e.created_at AS closed_at'
))
.
group
(
'id'
)
.
group
(
:id
,
:closed_at
,
:weight
,
:state
)
.
having
(
'closed_at = MIN(closed_at) OR closed_at IS NULL'
)
.
order
(
'closed_at ASC'
)
.
pluck
(
'id, closed_at, weight, state'
)
.
uniq
(
&
:first
)
.
map
{
|
attrs
|
attrs
.
drop
(
1
)
}
end
rel
.
order
(
'closed_at ASC'
)
.
pluck
(
'closed_at, weight, state'
)
.
map
{
|
attrs
|
Issue
.
new
(
*
attrs
)
}
rel
.
map
{
|
attrs
|
Issue
.
new
(
*
attrs
)
}
end
end
end
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