14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/llm_cost_tracker/ledger/store.rb', line 14
def insert(events, skip_existence_check: false)
events = Array(events)
return if events.empty?
insertable = skip_existence_check ? events : insertable_events(events)
return unless insertable.any?
LlmCostTracker::Call.transaction do
rows = insertable.map { |event| attributes_for(event) }
call_ids = insert_calls_returning_ids(rows, insertable)
insert_line_items(insertable, call_ids)
insert_call_tags(insertable, call_ids)
end
increment_rollups_safely(insertable) if LlmCostTracker.configuration.cache_rollups
end
|