diff options
author | Rémy Coutable <remy@rymai.me> | 2016-04-20 14:41:50 +0200 |
---|---|---|
committer | Robert Speicher <rspeicher@gmail.com> | 2016-04-20 15:43:32 -0400 |
commit | 3a7290f387ad6d568ddc5b102218c719dd42ed5d (patch) | |
tree | e1dda6b94476a9d69f024377cbb6ebbf42c548d3 | |
parent | da2e31549c256071d2488db1b4641bf1dda19afe (diff) | |
download | gitlab-ce-3a7290f387ad6d568ddc5b102218c719dd42ed5d.tar.gz |
Move Issue scopes from Issuable to Issue model
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r-- | app/finders/issuable_finder.rb | 40 | ||||
-rw-r--r-- | app/models/concerns/issuable.rb | 4 | ||||
-rw-r--r-- | app/models/issue.rb | 4 |
3 files changed, 24 insertions, 24 deletions
diff --git a/app/finders/issuable_finder.rb b/app/finders/issuable_finder.rb index 88ddeefa079..a85c214e4c4 100644 --- a/app/finders/issuable_finder.rb +++ b/app/finders/issuable_finder.rb @@ -113,26 +113,6 @@ class IssuableFinder end end - def due_date? - params[:due_date].present? && klass.column_names.include?('due_date') - end - - def filter_by_no_due_date? - due_date? && params[:due_date] == Issue::NoDueDate.name - end - - def filter_by_overdue? - due_date? && params[:due_date] == Issue::Overdue.name - end - - def filter_by_due_this_week? - due_date? && params[:due_date] == Issue::DueThisWeek.name - end - - def filter_by_due_this_month? - due_date? && params[:due_date] == Issue::DueThisMonth.name - end - def labels? params[:label_name].present? end @@ -320,6 +300,26 @@ class IssuableFinder items end + def filter_by_no_due_date? + due_date? && params[:due_date] == Issue::NoDueDate.name + end + + def filter_by_overdue? + due_date? && params[:due_date] == Issue::Overdue.name + end + + def filter_by_due_this_week? + due_date? && params[:due_date] == Issue::DueThisWeek.name + end + + def filter_by_due_this_month? + due_date? && params[:due_date] == Issue::DueThisMonth.name + end + + def due_date? + params[:due_date].present? && klass.column_names.include?('due_date') + end + def label_names params[:label_name].split(',') end diff --git a/app/models/concerns/issuable.rb b/app/models/concerns/issuable.rb index 7c2a92fa86a..afa2ca039ae 100644 --- a/app/models/concerns/issuable.rb +++ b/app/models/concerns/issuable.rb @@ -40,10 +40,6 @@ module Issuable scope :with_label, ->(title) { joins(:labels).where(labels: { title: title }) } scope :without_label, -> { joins("LEFT OUTER JOIN label_links ON label_links.target_type = '#{name}' AND label_links.target_id = #{table_name}.id").where(label_links: { id: nil }) } - scope :without_due_date, -> { where('issues.due_date IS NULL') } - scope :due_before, ->(date) { where('issues.due_date < ?', date) } - scope :due_between, ->(from_date, to_date) { where('issues.due_date >= ?', from_date).where('issues.due_date <= ?', to_date) } - scope :join_project, -> { joins(:project) } scope :references_project, -> { references(:project) } scope :non_archived, -> { join_project.where(projects: { archived: false }) } diff --git a/app/models/issue.rb b/app/models/issue.rb index 9a382fcda8d..ea1bfb776ee 100644 --- a/app/models/issue.rb +++ b/app/models/issue.rb @@ -46,6 +46,10 @@ class Issue < ActiveRecord::Base scope :open_for, ->(user) { opened.assigned_to(user) } scope :in_projects, ->(project_ids) { where(project_id: project_ids) } + scope :without_due_date, -> { where(due_date: nil) } + scope :due_before, ->(date) { where('issues.due_date < ?', date) } + scope :due_between, ->(from_date, to_date) { where('issues.due_date >= ?', from_date).where('issues.due_date <= ?', to_date) } + scope :order_due_date_asc, -> { reorder('issues.due_date IS NULL, issues.due_date ASC') } scope :order_due_date_desc, -> { reorder('issues.due_date IS NULL, issues.due_date DESC') } |