13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
# File 'lib/llm_cost_tracker/doctor/price_check.rb', line 13
def call
path = LlmCostTracker.configuration.prices_file
return bundled_check unless path
count = LlmCostTracker::Pricing::Registry.file_prices(path).size
metadata = LlmCostTracker::Pricing::Registry.file_metadata(path)
updated_at = metadata["updated_at"] || metadata[:updated_at]
return configured_check(:warn, path, count, "metadata.updated_at missing; #{REFRESH_COMMAND}") unless updated_at
age_days = (Date.today - Date.iso8601(updated_at.to_s)).to_i
if age_days > STALE_AFTER_DAYS
return configured_check(
:warn,
path,
count,
"updated_at=#{updated_at} is older than #{STALE_AFTER_DAYS} days; #{REFRESH_COMMAND}"
)
end
configured_check(:ok, path, count, "updated_at=#{updated_at}")
rescue Date::Error
configured_check(
:warn,
path,
count,
"metadata.updated_at=#{updated_at.inspect} is invalid; #{REFRESH_COMMAND}"
)
rescue LlmCostTracker::Error => e
Check.new(:error, "prices", e.message)
end
|