Class: LlmCostTracker::Storage::ActiveRecordPeriodTotals
- Inherits:
-
Object
- Object
- LlmCostTracker::Storage::ActiveRecordPeriodTotals
- Defined in:
- lib/llm_cost_tracker/storage/active_record_period_totals.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(periods, time:) ⇒ ActiveRecordPeriodTotals
constructor
A new instance of ActiveRecordPeriodTotals.
- #totals ⇒ Object
Constructor Details
#initialize(periods, time:) ⇒ ActiveRecordPeriodTotals
Returns a new instance of ActiveRecordPeriodTotals.
14 15 16 17 |
# File 'lib/llm_cost_tracker/storage/active_record_period_totals.rb', line 14 def initialize(periods, time:) @periods = ActiveRecordPeriods.valid_keys(periods) @time = time end |
Class Method Details
.call(periods, time:) ⇒ Object
10 11 12 |
# File 'lib/llm_cost_tracker/storage/active_record_period_totals.rb', line 10 def self.call(periods, time:) new(periods, time: time).totals end |
Instance Method Details
#totals ⇒ Object
19 20 21 22 23 24 |
# File 'lib/llm_cost_tracker/storage/active_record_period_totals.rb', line 19 def totals return {} if periods.empty? return ActiveRecordRollups.period_totals(periods, time: time) unless ActiveRecordInbox.enabled? snapshot_totals end |