diff options
author | Felipe Artur <felipefac@gmail.com> | 2016-05-19 18:30:38 -0400 |
---|---|---|
committer | Felipe Artur <felipefac@gmail.com> | 2016-05-24 16:51:43 -0400 |
commit | dac9b4212d700272160dff1e0a86c20cb72afedd (patch) | |
tree | f413722e3bfdedffef45f6c9f0f2bc50b571120e /app | |
parent | 45e516b8174c174951a97438c83fd659782e2347 (diff) | |
download | gitlab-ce-dac9b4212d700272160dff1e0a86c20cb72afedd.tar.gz |
Fix outer join when filtering milestonesissue_15221_2
Diffstat (limited to 'app')
-rw-r--r-- | app/finders/issuable_finder.rb | 4 | ||||
-rw-r--r-- | app/models/concerns/issuable.rb | 2 |
2 files changed, 4 insertions, 2 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 0e3dfa74ac4..8ed3ccf1c02 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -250,12 +250,12 @@ class IssuableFinder def by_milestone(items) if milestones? if filter_by_no_milestone? - items = items.where(milestone_id: [-1, nil]) + items = items.left_joins_milestones.where(milestone_id: [-1, nil]) elsif filter_by_upcoming_milestone? upcoming_ids = Milestone.upcoming_ids_by_projects(projects) items = items.left_joins_milestones.where(milestone_id: upcoming_ids) else - items = items.left_joins_milestones.where(milestones: { title: params[:milestone_title] }) + items = items.with_milestone(params[:milestone_title]) if projects items = items.where(milestones: { project_id: projects }) diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index d34308204e5..91315b3459f 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -31,6 +31,7 @@ module Issuable scope :unassigned, -> { where("assignee_id IS NULL") } scope :of_projects, ->(ids) { where(project_id: ids) } scope :of_milestones, ->(ids) { where(milestone_id: ids) } + scope :with_milestone, ->(title) { left_joins_milestones.where(milestones: { title: title }) } scope :opened, -> { with_state(:opened, :reopened) } scope :only_opened, -> { with_state(:opened) } scope :only_reopened, -> { with_state(:reopened) } @@ -45,6 +46,7 @@ module Issuable scope :references_project, -> { references(:project) } scope :non_archived, -> { join_project.where(projects: { archived: false }) } + delegate :name, :email, to: :author, |