Class: LlmCostTracker::Storage::ActiveRecordRollupBatch

Inherits:
Object
  • Object
show all
Defined in:
lib/llm_cost_tracker/storage/active_record_rollup_batch.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(events) ⇒ ActiveRecordRollupBatch

Returns a new instance of ActiveRecordRollupBatch.



14
15
16
# File 'lib/llm_cost_tracker/storage/active_record_rollup_batch.rb', line 14

def initialize(events)
  @events = events
end

Class Method Details

.rows(events) ⇒ Object



10
11
12
# File 'lib/llm_cost_tracker/storage/active_record_rollup_batch.rb', line 10

def self.rows(events)
  new(events).rows
end

Instance Method Details

#rowsObject



18
19
20
21
22
23
24
25
26
# File 'lib/llm_cost_tracker/storage/active_record_rollup_batch.rb', line 18

def rows
  totals.map do |(period, period_start), total_cost|
    {
      period: period,
      period_start: period_start,
      total_cost: total_cost
    }
  end
end