Module: LlmCostTracker::Ledger::Period
- Defined in:
- lib/llm_cost_tracker/ledger/period.rb,
lib/llm_cost_tracker/ledger/period/totals.rb,
app/models/llm_cost_tracker/ledger/period/total.rb,
app/models/llm_cost_tracker/ledger/period/grouping.rb
Defined Under Namespace
Modules: Grouping
Classes: Total, Totals
Constant Summary
collapse
- PERIODS =
{
monthly: "month",
daily: "day"
}.freeze
Class Method Summary
collapse
Class Method Details
.bucket(period, time) ⇒ Object
26
27
28
|
# File 'lib/llm_cost_tracker/ledger/period.rb', line 26
def bucket(period, time)
range_start(period, time).to_date
end
|
.range_start(period, time) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/llm_cost_tracker/ledger/period.rb', line 17
def range_start(period, time)
utc_time = time.to_time.utc
case period
when :monthly then utc_time.beginning_of_month
when :daily then utc_time.beginning_of_day
end
end
|
.valid_keys(periods) ⇒ Object
13
14
15
|
# File 'lib/llm_cost_tracker/ledger/period.rb', line 13
def valid_keys(periods)
periods.map(&:to_sym).select { |period| PERIODS.key?(period) }
end
|