Module: LlmCostTracker::Retention
- Defined in:
- lib/llm_cost_tracker/retention.rb
Constant Summary collapse
- DEFAULT_BATCH_SIZE =
5_000
Class Method Summary collapse
Class Method Details
.prune(older_than:, batch_size: DEFAULT_BATCH_SIZE, now: Time.now.utc) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/llm_cost_tracker/retention.rb', line 8 def prune(older_than:, batch_size: DEFAULT_BATCH_SIZE, now: Time.now.utc) batch_size = batch_size.to_i raise ArgumentError, "batch_size must be positive: #{batch_size.inspect}" unless batch_size.positive? cutoff = resolve_cutoff(older_than, now) require_relative "ledger" deleted = 0 loop do batch = prune_batch(cutoff, batch_size) deleted += batch break if batch < batch_size end deleted end |