Module: LlmCostTracker::Ledger::Schema::CallRollups

Defined in:
lib/llm_cost_tracker/ledger/schema/call_rollups.rb

Constant Summary collapse

REQUIRED_COLUMNS =
%w[period period_start currency provider total_cost created_at updated_at].freeze
UNIQUE_COLUMNS =
%i[period period_start currency provider].freeze

Class Method Summary collapse

Class Method Details

.current_schema_errorsObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/llm_cost_tracker/ledger/schema/call_rollups.rb', line 13

def current_schema_errors
  connection = LlmCostTracker::CallRollup.connection
  Adapter.ensure_supported!(connection)
  table_name = LlmCostTracker::CallRollup.table_name
  return ["#{table_name} table is missing"] unless connection.data_source_exists?(table_name)

  columns = LlmCostTracker::CallRollup.columns_hash
  cache = @schema_capabilities
  return cache.fetch(:errors) if cache && cache.fetch(:columns).equal?(columns)

  errors = compute_errors(connection, table_name, columns)
  @schema_capabilities = { columns: columns, errors: errors }
  errors
end