diff options
author | Andreas Brandl <abrandl@gitlab.com> | 2018-10-28 18:08:37 +0300 |
---|---|---|
committer | Andreas Brandl <abrandl@gitlab.com> | 2018-12-03 23:26:48 +0300 |
commit | f2ec9d2d34ebd0650458896af354386c4e73ef26 (patch) | |
tree | 7cbb796bf12aa1268181352a3ff3844706718663 /lib | |
parent | f3a931517735268487dfee9a129280dc06835fad (diff) |
Add ExactCountStrategy.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/database/count.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/gitlab/database/count.rb b/lib/gitlab/database/count.rb index fc61ee48832..7b7fd3148fa 100644 --- a/lib/gitlab/database/count.rb +++ b/lib/gitlab/database/count.rb @@ -57,6 +57,19 @@ module Gitlab ReltuplesCountStrategy.new(table_names).count end + class ExactCountStrategy + attr_reader :models + def initialize(models) + @models = models + end + + def count + models.each_with_object({}) do |model, data| + data[model] = model.count + end + end + end + class ReltuplesCountStrategy attr_reader :table_names |