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
path: root/app
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-12-17 18:12:33 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-12-17 18:12:33 +0300
commit4847ec0f5040b52509876b7df47cb7a304f7a89a (patch)
treef6344102fcf323bdea3ca802694c19f6a118bf61 /app
parent42deff0c17c1a34f716a299db79bb9c3788c265f (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app')
-rw-r--r--app/models/namespace.rb1
-rw-r--r--app/models/work_item.rb2
-rw-r--r--app/models/work_items/dates_source.rb28
3 files changed, 31 insertions, 0 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index acdb96fb4e6..c665c2278a5 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -81,6 +81,7 @@ class Namespace < ApplicationRecord
has_one :cluster_enabled_grant, inverse_of: :namespace, class_name: 'Clusters::ClusterEnabledGrant'
has_many :work_items, inverse_of: :namespace
+ has_many :work_items_dates_source, inverse_of: :namespace, class_name: 'WorkItems::DatesSource'
has_many :issues, inverse_of: :namespace
has_many :timelog_categories, class_name: 'TimeTracking::TimelogCategory'
diff --git a/app/models/work_item.rb b/app/models/work_item.rb
index d4cac3b6c44..77f684e3578 100644
--- a/app/models/work_item.rb
+++ b/app/models/work_item.rb
@@ -12,8 +12,10 @@ class WorkItem < Issue
self.inheritance_column = :_type_disabled
belongs_to :namespace, inverse_of: :work_items
+
has_one :parent_link, class_name: '::WorkItems::ParentLink', foreign_key: :work_item_id
has_one :work_item_parent, through: :parent_link, class_name: 'WorkItem'
+ has_one :dates_source, class_name: 'WorkItems::DatesSource', foreign_key: 'issue_id', inverse_of: :work_item
has_many :child_links, class_name: '::WorkItems::ParentLink', foreign_key: :work_item_parent_id
has_many :work_item_children, through: :child_links, class_name: 'WorkItem',
diff --git a/app/models/work_items/dates_source.rb b/app/models/work_items/dates_source.rb
new file mode 100644
index 00000000000..89528e95007
--- /dev/null
+++ b/app/models/work_items/dates_source.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+module WorkItems
+ class DatesSource < ApplicationRecord
+ self.table_name = 'work_item_dates_sources'
+
+ # namespace is required as the sharding key
+ belongs_to :namespace, inverse_of: :work_items_dates_source
+ belongs_to :work_item, foreign_key: 'issue_id', inverse_of: :dates_source
+
+ belongs_to :due_date_sourcing_work_item, class_name: 'WorkItem'
+ belongs_to :start_date_sourcing_work_item, class_name: 'WorkItem'
+
+ belongs_to :due_date_sourcing_milestone, class_name: 'Milestone'
+ belongs_to :start_date_sourcing_milestone, class_name: 'Milestone'
+
+ before_validation :set_namespace
+
+ private
+
+ def set_namespace
+ return if work_item.blank?
+ return if work_item.namespace == namespace
+
+ self.namespace = work_item.namespace
+ end
+ end
+end