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:
authorMayra Cabrera <mcabrera@gitlab.com>2019-06-13 00:11:14 +0300
committerMayra Cabrera <mcabrera@gitlab.com>2019-06-25 17:54:47 +0300
commitbde41ee866d0fe0b1bb5ece1130fb6e24d95ad17 (patch)
tree8d52bc34eb73832357142b1cf5cb34a372b27f7f /app
parentd6c7d4c48db51fdc3eb479e53d40ce4358695218 (diff)
Add two new ActiveRecord models
- Namespace::Storagestatistics will persist root namespace statistics - Namespace::AggregationSchedule will save information when a new update to the namespace statistics needs to be scheduled Both tables use 'namespace_id' as primary key
Diffstat (limited to 'app')
-rw-r--r--app/models/namespace.rb2
-rw-r--r--app/models/namespace/aggregation_schedule.rb7
-rw-r--r--app/models/namespace/root_storage_statistics.rb10
3 files changed, 19 insertions, 0 deletions
diff --git a/app/models/namespace.rb b/app/models/namespace.rb
index 3c270c7396a..f9b53b2b70a 100644
--- a/app/models/namespace.rb
+++ b/app/models/namespace.rb
@@ -35,6 +35,8 @@ class Namespace < ApplicationRecord
belongs_to :parent, class_name: "Namespace"
has_many :children, class_name: "Namespace", foreign_key: :parent_id
has_one :chat_team, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
+ has_one :root_storage_statistics, class_name: 'Namespace::RootStorageStatistics'
+ has_one :aggregation_schedule, class_name: 'Namespace::AggregationSchedule'
validates :owner, presence: true, unless: ->(n) { n.type == "Group" }
validates :name,
diff --git a/app/models/namespace/aggregation_schedule.rb b/app/models/namespace/aggregation_schedule.rb
new file mode 100644
index 00000000000..43afd0b954c
--- /dev/null
+++ b/app/models/namespace/aggregation_schedule.rb
@@ -0,0 +1,7 @@
+# frozen_string_literal: true
+
+class Namespace::AggregationSchedule < ApplicationRecord
+ self.primary_key = :namespace_id
+
+ belongs_to :namespace
+end
diff --git a/app/models/namespace/root_storage_statistics.rb b/app/models/namespace/root_storage_statistics.rb
new file mode 100644
index 00000000000..de28eb6b37f
--- /dev/null
+++ b/app/models/namespace/root_storage_statistics.rb
@@ -0,0 +1,10 @@
+# frozen_string_literal: true
+
+class Namespace::RootStorageStatistics < ApplicationRecord
+ self.primary_key = :namespace_id
+
+ belongs_to :namespace
+ has_one :route, through: :namespace
+
+ delegate :all_projects, to: :namespace
+end