diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-03-23 10:35:54 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-03-23 10:35:54 +0000 |
commit | 703f7c5d579a6ab6d7592c24f8e3f2813d9d1703 (patch) | |
tree | 831b73106a0e4fce56bdea27b23229f7856d8f0f /app | |
parent | 3b39ce325263028553c6019cc894024c207644ea (diff) | |
parent | 100e3e7601dd4d3033cd8292814273dd0354722e (diff) | |
download | gitlab-ce-703f7c5d579a6ab6d7592c24f8e3f2813d9d1703.tar.gz |
Merge branch 'fix-sorting-by-votes-on-groups-page' into 'master'
Fix sorting issues/mrs by votes on the groups page
Closes #14394
The `non_archived` scope applied here https://gitlab.com/gitlab-org/gitlab-ce/blob/master/app/controllers/concerns/issues_action.rb#L5 overrides the previous `ORDER BY` applied inside the IssuesFinder, with the default scope of the Project model, resulting in SQL errors.
```ruby
Issue.reorder(created_at: :desc).joins(:project).to_sql
=> "SELECT issues.*
FROM issues INNER JOIN projects ON projects.id = issues.project_id
ORDER BY issues.created_at DESC"
Issue.reorder(created_at: :desc).joins(:project).merge(Project.non_archived).to_sql
=> "SELECT issues.*
FROM issues INNER JOIN projects ON projects.id = issues.project_id
WHERE projects.archived = 'f'
ORDER BY projects.id DESC"
Issue.reorder(created_at: :desc).joins(:project).merge(Project.non_archived.only(:where)).to_sql
=> "SELECT issues.*
FROM issues INNER JOIN projects ON projects.id = issues.project_id
WHERE projects.archived = 'f'
ORDER BY issues.created_at DESC"
```
/cc @yorickpeterse
See merge request !3333
Diffstat (limited to 'app')
-rw-r--r-- | app/models/concerns/issuable.rb | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 476e1ce7af0..cf5b2c71675 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -41,7 +41,7 @@ module Issuable scope :join_project, -> { joins(:project) } scope :references_project, -> { references(:project) } - scope :non_archived, -> { join_project.merge(Project.non_archived) } + scope :non_archived, -> { join_project.merge(Project.non_archived.only(:where)) } delegate :name, :email, |