Commit b4301f64 authored by Andreas Brandl's avatar Andreas Brandl
Browse files

Add ExactCountStrategy.

parent e5706c39405c
......@@ -57,6 +57,19 @@ def self.reltuples_from_recently_updated(table_names)
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
......
......@@ -66,6 +66,16 @@
expect(described_class.approximate_counts(models)).to eq({ Project => 3, Identity => 1 })
end
end
describe Gitlab::Database::Count::ExactCountStrategy do
subject { described_class.new(models).count }
it 'counts all models' do
models.each { |model| expect(model).to receive(:count).and_call_original }
expect(subject).to eq({ Project => 3, Identity => 1 })
end
end
end
end
end
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment