diff options
author | Stan Hu <stanhu@gmail.com> | 2018-05-26 00:28:16 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2018-05-26 08:58:43 +0300 |
commit | b6125f7045d2bed4aadf798dde4c547e2047e039 (patch) | |
tree | d8e522ca729b2f755229a6fea2fa0fa9833f154e /app/helpers/count_helper.rb | |
parent | 50c8ed2bf498c69d3d52ba1451274e3fbf438429 (diff) |
Fix fast admin counters not working when PostgreSQL has secondaries
This commit does a number of things:
1. Reduces the number of queries needed by perform a single query to get all
the tuples for the relevant rows.
2. Uses a transaction to query the tuple counts to ensure that the data
is retrieved from the primary.
Closes #46742
Diffstat (limited to 'app/helpers/count_helper.rb')
-rw-r--r-- | app/helpers/count_helper.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/helpers/count_helper.rb b/app/helpers/count_helper.rb index 24ee62e68ba..5cd98f40f78 100644 --- a/app/helpers/count_helper.rb +++ b/app/helpers/count_helper.rb @@ -1,5 +1,9 @@ module CountHelper - def approximate_count_with_delimiters(model) - number_with_delimiter(Gitlab::Database::Count.approximate_count(model)) + def approximate_count_with_delimiters(count_data, model) + count = count_data[model] + + raise "Missing model #{model} from count data" unless count + + number_with_delimiter(count) end end |