Class: KMDB::Services::Partitioner
- Inherits:
-
Object
- Object
- KMDB::Services::Partitioner
- Defined in:
- lib/kmdb/services/partitioner.rb
Instance Method Summary collapse
-
#initialize(model:, min_date: nil, max_date: nil, days_per_partition: nil) ⇒ Partitioner
constructor
A new instance of Partitioner.
- #run ⇒ Object
Constructor Details
#initialize(model:, min_date: nil, max_date: nil, days_per_partition: nil) ⇒ Partitioner
Returns a new instance of Partitioner.
6 7 8 9 10 11 |
# File 'lib/kmdb/services/partitioner.rb', line 6 def initialize(model:, min_date: nil, max_date: nil, days_per_partition: nil) @model = model @min_date = min_date || Date.parse(ENV.fetch('KMDB_MIN_DATE')) @max_date = max_date || Date.parse(ENV.fetch('KMDB_MAX_DATE')) @days_per_partition = days_per_partition || Integer(ENV.fetch('KMDB_DAYS_PER_PARTITION')) end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/kmdb/services/partitioner.rb', line 13 def run while true last_limit = _get_last_limit || @min_date break if last_limit > @max_date next_limit = last_limit + @days_per_partition _add_partition(next_limit) end end |