13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/llm_cost_tracker/ledger/store.rb', line 13
def insert_many(events)
events = Array(events)
return [] if events.empty?
insertable = insertable_events(events)
if insertable.any?
LlmCostTracker::Call.transaction do
rows = insertable.map { |event| attributes_for(event) }
LlmCostTracker::Call.insert_all!(rows, record_timestamps: true, returning: false)
call_ids = call_ids_for(insertable)
insert_line_items(insertable, call_ids)
insert_call_tags(insertable, call_ids)
Ledger::Rollups.increment_many!(insertable)
end
end
events
end
|