summaryrefslogtreecommitdiff
path: root/app/models/iteration.rb
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 11:18:50 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-06-18 11:18:50 +0000
commit8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781 (patch)
treea77e7fe7a93de11213032ed4ab1f33a3db51b738 /app/models/iteration.rb
parent00b35af3db1abfe813a778f643dad221aad51fca (diff)
downloadgitlab-ce-8c7f4e9d5f36cff46365a7f8c4b9c21578c1e781.tar.gz
Add latest changes from gitlab-org/gitlab@13-1-stable-ee
Diffstat (limited to 'app/models/iteration.rb')
-rw-r--r--app/models/iteration.rb25
1 files changed, 20 insertions, 5 deletions
diff --git a/app/models/iteration.rb b/app/models/iteration.rb
index 1acd08f2063..2bda0725471 100644
--- a/app/models/iteration.rb
+++ b/app/models/iteration.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true
class Iteration < ApplicationRecord
- include Timebox
-
self.table_name = 'sprints'
attr_accessor :skip_future_date_validation
@@ -15,9 +13,6 @@ class Iteration < ApplicationRecord
include AtomicInternalId
- has_many :issues, foreign_key: 'sprint_id'
- has_many :merge_requests, foreign_key: 'sprint_id'
-
belongs_to :project
belongs_to :group
@@ -33,6 +28,12 @@ class Iteration < ApplicationRecord
scope :upcoming, -> { with_state(:upcoming) }
scope :started, -> { with_state(:started) }
+ 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
+
state_machine :state_enum, initial: :upcoming do
event :start do
transition upcoming: :started
@@ -62,6 +63,14 @@ class Iteration < ApplicationRecord
else iterations.upcoming
end
end
+
+ def reference_prefix
+ '*iteration:'
+ end
+
+ def reference_pattern
+ nil
+ end
end
def state
@@ -72,6 +81,10 @@ class Iteration < ApplicationRecord
self.state_enum = STATE_ENUM_MAP[value]
end
+ def resource_parent
+ group || project
+ end
+
private
def start_or_due_dates_changed?
@@ -98,3 +111,5 @@ class Iteration < ApplicationRecord
end
end
end
+
+Iteration.prepend_if_ee('EE::Iteration')