Class: Gitlab::Database::Count::ExactCountStrategy
- Inherits:
-
Object
- Object
- Gitlab::Database::Count::ExactCountStrategy
- Defined in:
- lib/gitlab/database/count/exact_count_strategy.rb
Overview
This strategy performs an exact count on the model.
This is guaranteed to be accurate, however it also scans the whole table. Hence, there are no guarantees with respect to runtime.
Note that for very large tables, this may even timeout.
Instance Attribute Summary collapse
-
#models ⇒ Object
readonly
Returns the value of attribute models.
Instance Method Summary collapse
- #count ⇒ Object
-
#initialize(models) ⇒ ExactCountStrategy
constructor
A new instance of ExactCountStrategy.
Constructor Details
#initialize(models) ⇒ ExactCountStrategy
Returns a new instance of ExactCountStrategy.
16 17 18 |
# File 'lib/gitlab/database/count/exact_count_strategy.rb', line 16 def initialize(models) @models = models end |
Instance Attribute Details
#models ⇒ Object (readonly)
Returns the value of attribute models.
14 15 16 |
# File 'lib/gitlab/database/count/exact_count_strategy.rb', line 14 def models @models end |
Instance Method Details
#count ⇒ Object
20 21 22 23 24 |
# File 'lib/gitlab/database/count/exact_count_strategy.rb', line 20 def count models.index_with(&:count) rescue *CONNECTION_ERRORS {} end |