summaryrefslogtreecommitdiff
path: root/app/models/milestone.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-05 12:09:15 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-05 12:09:15 +0000
commit20d564f1064622ef0623434372ac3ceb03173331 (patch)
tree000d95440566cd189ea774168c9756bcc8fc5fae /app/models/milestone.rb
parent26384c9a61da9922b8fa4b8351d4e42d51661b37 (diff)
downloadgitlab-ce-20d564f1064622ef0623434372ac3ceb03173331.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models/milestone.rb')
-rw-r--r--app/models/milestone.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/app/models/milestone.rb b/app/models/milestone.rb
index f709e518047..b3278f48aa9 100644
--- a/app/models/milestone.rb
+++ b/app/models/milestone.rb
@@ -59,6 +59,12 @@ class Milestone < ApplicationRecord
where(project_id: projects).or(where(group_id: groups))
end
+ scope :within_timeframe, -> (start_date, end_date) do
+ where('start_date is not NULL or due_date is not NULL')
+ .where('start_date is NULL or start_date <= ?', end_date)
+ .where('due_date is NULL or due_date >= ?', start_date)
+ end
+
scope :order_by_name_asc, -> { order(Arel::Nodes::Ascending.new(arel_table[:title].lower)) }
scope :reorder_by_due_date_asc, -> { reorder(Gitlab::Database.nulls_last_order('due_date', 'ASC')) }