summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-10-13 15:12:05 +0200
committerMatija Čupić <matteeyah@gmail.com>2018-10-13 15:17:32 +0200
commit5c373a5912d450906febb271a19a9a4ac06077eb (patch)
treeeb7000c34b76aa074add2bfb571d3091a3ce1c51
parent78bc4a6aece07fd73d99d7731feccaac41dd912f (diff)
downloadgitlab-ce-51098-verify-counts-time-out-in-usage-ping-for-gitlab-com.tar.gz
This extrapolates the internal pipeline count by deducing the external pipeline count from the approx count of total pipelines.
-rw-r--r--lib/gitlab/usage_data.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/gitlab/usage_data.rb b/lib/gitlab/usage_data.rb
index ef13b1dad5c..1e9c5acdd34 100644
--- a/lib/gitlab/usage_data.rb
+++ b/lib/gitlab/usage_data.rb
@@ -34,12 +34,11 @@ module Gitlab
# rubocop:disable Metrics/AbcSize
# rubocop: disable CodeReuse/ActiveRecord
def system_usage_data
- {
+ base_counts = {
counts: {
assignee_lists: count(List.assignee),
boards: count(Board),
- ci_builds: Gitlab::Database::Count.approximate_counts([::Ci::Build]),
- ci_internal_pipelines: Gitlab::Database::Count.approximate_counts([::Ci::Pipeline.internal]),
+ ci_builds: Gitlab::Database::Count.approximate_counts([::Ci::Build]).values.first,
ci_external_pipelines: count(::Ci::Pipeline.external),
ci_pipeline_config_auto_devops: count(::Ci::Pipeline.auto_devops_source),
ci_pipeline_config_repository: count(::Ci::Pipeline.repository_source),
@@ -81,8 +80,14 @@ module Gitlab
todos: count(Todo),
uploads: count(Upload),
web_hooks: count(WebHook)
- }.merge(services_usage)
+ }
}
+
+ base_counts[:counts].merge!(services_usage)
+ # Use approx counts for builds and extrapolating internal pipelines to
+ # avoid statement timeouts
+ base_counts[:counts][:ci_internal_pipelines] = base_counts[:counts][:ci_builds] - base_counts[:counts][:ci_external_pipelines]
+ base_counts
end
# rubocop: enable CodeReuse/ActiveRecord