Module: LlmCostTracker::TagQuery

Defined in:
lib/llm_cost_tracker/tag_query.rb

Class Method Summary collapse

Class Method Details

.apply(model, tags) ⇒ Object



8
9
10
11
12
13
14
15
# File 'lib/llm_cost_tracker/tag_query.rb', line 8

def apply(model, tags)
  normalized_tags = normalize_tags(tags)
  return model.all if normalized_tags.empty?

  return json_query(model, normalized_tags) if model.tags_json_column?

  text_query(model, normalized_tags)
end

.normalize_tags(tags) ⇒ Object



17
18
19
# File 'lib/llm_cost_tracker/tag_query.rb', line 17

def normalize_tags(tags)
  (tags || {}).to_h.transform_keys(&:to_s).transform_values(&:to_s)
end