summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlessio Caiazza <acaiazza@gitlab.com>2019-04-15 13:51:30 +0200
committerStan Hu <stanhu@gmail.com>2019-05-02 21:30:43 -0700
commitcb72d9efd2db30cd2df1d3bad445ffb00e5b3c0f (patch)
treeea8b8f9a36b8c29be121992614223f16ad382a5a
parentb12c19d3dec11b0ab1d6d5c171611e7178a5b733 (diff)
downloadgitlab-ce-cb72d9efd2db30cd2df1d3bad445ffb00e5b3c0f.tar.gz
Add packages_size to ProjectStatistics
This new field will allow to keep track of the storage used by the packages features, it provides also aggregation at namespace level.
-rw-r--r--db/schema.rb1
-rw-r--r--spec/models/project_statistics_spec.rb4
2 files changed, 3 insertions, 2 deletions
diff --git a/db/schema.rb b/db/schema.rb
index e90a14e2c98..4ffeb32e6b7 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -2463,6 +2463,7 @@ ActiveRecord::Schema.define(version: 20190426180107) do
t.bigint "packages_size"
t.bigint "shared_runners_seconds", default: 0, null: false
t.datetime "shared_runners_seconds_last_reset"
+ t.bigint "packages_size"
t.index ["namespace_id"], name: "index_project_statistics_on_namespace_id", using: :btree
t.index ["project_id"], name: "index_project_statistics_on_project_id", unique: true, using: :btree
end
diff --git a/spec/models/project_statistics_spec.rb b/spec/models/project_statistics_spec.rb
index 738398a06f9..914f0c2394c 100644
--- a/spec/models/project_statistics_spec.rb
+++ b/spec/models/project_statistics_spec.rb
@@ -124,7 +124,7 @@ describe ProjectStatistics do
end
describe '.increment_statistic' do
- shared_examples 'a statistic that increases storage_size' do
+ shared_examples 'a statistic that also increases storage_size' do
it 'increases the statistic by that amount' do
expect { described_class.increment_statistic(project.id, stat, 13) }
.to change { statistics.reload.send(stat) || 0 }
@@ -153,7 +153,7 @@ describe ProjectStatistics do
context 'when the amount is 0' do
it 'does not execute a query' do
project
- expect { described_class.increment_statistic(project.id, :build_artifacts_size, 0) }
+ expect { described_class.increment_statistic(project.id, stat, 0) }
.not_to exceed_query_limit(0)
end
end