Class: LlmCostTracker::Ledger::Rollups
- Inherits:
-
Object
- Object
- LlmCostTracker::Ledger::Rollups
- Defined in:
- lib/llm_cost_tracker/ledger/rollups.rb,
lib/llm_cost_tracker/ledger/rollups/upsert_sql.rb
Defined Under Namespace
Classes: UpsertSql
Constant Summary collapse
- DEFAULT_CURRENCY =
"USD"
Class Method Summary collapse
Class Method Details
.decrement!(call_rows) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/llm_cost_tracker/ledger/rollups.rb', line 27 def decrement!(call_rows) totals = period_decrement_totals(call_rows) return if totals.empty? apply_decrements(totals) end |
.increment!(event) ⇒ Object
14 15 16 17 18 |
# File 'lib/llm_cost_tracker/ledger/rollups.rb', line 14 def increment!(event) return unless event.total_cost upsert_call_rollups(period_rows(event)) end |
.increment_many!(events) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/llm_cost_tracker/ledger/rollups.rb', line 20 def increment_many!(events) events = Array(events).select(&:total_cost) return if events.empty? upsert_call_rollups(period_rows_for_events(events)) end |