13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/llm_cost_tracker/price_sync/validator.rb', line 13
def validate_batch(merged_prices, existing_registry:)
merged_prices.each_with_object(Result.new(accepted: {}, rejected: [], flagged: [])) do |(model, price), result|
old_price = normalize_entry(existing_registry[model])
status, reason = validate(new_price: price, old_price: old_price)
case status
when :rejected
result.rejected << Issue.new(model: model, reason: reason, old_price: old_price, new_price: price)
when :flagged
result.flagged << Issue.new(model: model, reason: reason, old_price: old_price, new_price: price)
result.accepted[model] = price
else
result.accepted[model] = price
end
end
end
|