Module: LlmCostTracker::Ledger::Schema::Base

Included in:
CallLineItems, CallRollups, CallTags, Calls, Ingestion::InboxEntries, Ingestion::Leases
Defined in:
lib/llm_cost_tracker/ledger/schema/base.rb

Instance Method Summary collapse

Instance Method Details

#columns(*names) ⇒ Object



15
16
17
# File 'lib/llm_cost_tracker/ledger/schema/base.rb', line 15

def columns(*names)
  @required_columns = names.map(&:to_s).freeze
end

#current_schema_errorsObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/llm_cost_tracker/ledger/schema/base.rb', line 23

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

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

  errors = column_errors(columns_hash)
  @schema_capabilities = { columns: columns_hash, errors: errors }
  errors
end

#modelObject



11
12
13
# File 'lib/llm_cost_tracker/ledger/schema/base.rb', line 11

def model
  @model ||= LlmCostTracker.const_get(detect_model_name)
end

#required_columnsObject



19
20
21
# File 'lib/llm_cost_tracker/ledger/schema/base.rb', line 19

def required_columns
  @required_columns || [].freeze
end