Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-05-27 03:08:11 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2020-05-27 03:08:11 +0300
commita78d7d5c667a0844e52419f11cb83a9ac60ee6d2 (patch)
treee317ab1400f6c7e836f8d08d4deea205ad343c39 /app/models
parentea335f33ff8c6870e641385a254c1f993bb04038 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/models')
-rw-r--r--app/models/alert_management/alert.rb14
-rw-r--r--app/models/iteration.rb10
2 files changed, 17 insertions, 7 deletions
diff --git a/app/models/alert_management/alert.rb b/app/models/alert_management/alert.rb
index be51dab5d68..630f957e681 100644
--- a/app/models/alert_management/alert.rb
+++ b/app/models/alert_management/alert.rb
@@ -102,7 +102,7 @@ module AlertManagement
scope :order_start_time, -> (sort_order) { order(started_at: sort_order) }
scope :order_end_time, -> (sort_order) { order(ended_at: sort_order) }
- scope :order_events_count, -> (sort_order) { order(events: sort_order) }
+ scope :order_event_count, -> (sort_order) { order(events: sort_order) }
scope :order_severity, -> (sort_order) { order(severity: sort_order) }
scope :order_status, -> (sort_order) { order(status: sort_order) }
@@ -110,12 +110,12 @@ module AlertManagement
def self.sort_by_attribute(method)
case method.to_s
- when 'start_time_asc' then order_start_time(:asc)
- when 'start_time_desc' then order_start_time(:desc)
- when 'end_time_asc' then order_end_time(:asc)
- when 'end_time_desc' then order_end_time(:desc)
- when 'events_count_asc' then order_events_count(:asc)
- when 'events_count_desc' then order_events_count(:desc)
+ when 'started_at_asc' then order_start_time(:asc)
+ when 'started_at_desc' then order_start_time(:desc)
+ when 'ended_at_asc' then order_end_time(:asc)
+ when 'ended_at_desc' then order_end_time(:desc)
+ when 'event_count_asc' then order_event_count(:asc)
+ when 'event_count_desc' then order_event_count(:desc)
when 'severity_asc' then order_severity(:asc)
when 'severity_desc' then order_severity(:desc)
when 'status_asc' then order_status(:asc)
diff --git a/app/models/iteration.rb b/app/models/iteration.rb
index 0f993a10542..2bda0725471 100644
--- a/app/models/iteration.rb
+++ b/app/models/iteration.rb
@@ -28,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
@@ -75,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?