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/lib
diff options
context:
space:
mode:
authorAndreas Brandl <abrandl@gitlab.com>2018-10-29 11:54:33 +0300
committerAndreas Brandl <abrandl@gitlab.com>2018-12-03 23:26:51 +0300
commit9bb7c690c40a2a35829fc05015e5afcde578c38b (patch)
tree61367869996f0866fd53b69cca0027e3dc002682 /lib
parent3266642739b58d8f54733bfcd399b523d963c2aa (diff)
Fix rubocop offenses.
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab/database/count.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/gitlab/database/count.rb b/lib/gitlab/database/count.rb
index 8af462da4a6..ed3510f1afc 100644
--- a/lib/gitlab/database/count.rb
+++ b/lib/gitlab/database/count.rb
@@ -40,7 +40,7 @@ module Gitlab
if strategy.enabled?
models_with_missing_counts = models - counts_by_model.keys
- return counts_by_model if models_with_missing_counts.empty?
+ break if models_with_missing_counts.empty?
counts = strategy.new(models_with_missing_counts).count
@@ -139,6 +139,7 @@ module Gitlab
LEFT JOIN pg_stat_user_tables ON pg_class.relname = pg_stat_user_tables.relname
WHERE pg_class.relname IN (#{table_names.map { |table| "'#{table}'" }.join(',')})
SQL
+
if check_statistics
base_query + "AND (last_vacuum > #{time} OR last_autovacuum > #{time} OR last_analyze > #{time} OR last_autoanalyze > #{time})"
else
@@ -177,6 +178,7 @@ module Gitlab
end
private
+
def perform_count(model, estimate)
# If we estimate 0, we may not have statistics at all. Don't use them.
return nil unless estimate && estimate > 0
@@ -193,10 +195,10 @@ module Gitlab
def tablesample_count(model, estimate)
portion = (TABLESAMPLE_ROW_TARGET.to_f / estimate).round(4)
- inverse = 1/portion
+ inverse = 1 / portion
query = <<~SQL
SELECT (COUNT(*)*#{inverse})::integer AS count
- FROM #{model.table_name} TABLESAMPLE SYSTEM (#{portion*100})
+ FROM #{model.table_name} TABLESAMPLE SYSTEM (#{portion * 100})
SQL
rows = ActiveRecord::Base.connection.select_all(query)