Class: PartitionGardener::Layout::CalendarYear

Inherits:
Object
  • Object
show all
Defined in:
lib/partition_gardener/layout/calendar_year.rb

Constant Summary collapse

DEFAULT_ACTIVE_YEARS =
Strategy::DateRange::DEFAULT_ACTIVE_YEARS

Class Method Summary collapse

Class Method Details

.active_end(active_start:, active_years: DEFAULT_ACTIVE_YEARS) ⇒ Object



7
8
9
# File 'lib/partition_gardener/layout/calendar_year.rb', line 7

def active_end(active_start:, active_years: DEFAULT_ACTIVE_YEARS)
  DateCalendar.add_years(active_start, active_years)
end

.build_segments(config:, active_start:, active_end:, hot_years:) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/partition_gardener/layout/calendar_year.rb', line 11

def build_segments(config:, active_start:, active_end:, hot_years:)
  strategy = Strategy::DateRange.new(config.merge(bucket: :year))
  buckets = strategy.send(:each_bucket_in_range, active_start, active_end)

  ZoneSegments.build_filler_and_hot_segments(
    table_name: config[:table_name],
    buckets: buckets,
    hot_buckets: hot_years,
    active_start: active_start,
    active_end: active_end,
    hot_bucket_name: config[:partition_name_format],
    bucket_end: ->(bucket) { DateCalendar.beginning_of_year(DateCalendar.next_year(bucket)) }
  )
end