mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 05:09:38 +02:00
* Benchmarking setup * Get demo data working in benchmark scenario * Finalize default demo scenario * Finalize benchmarking setup
63 lines
2 KiB
Ruby
63 lines
2 KiB
Ruby
namespace :demo_data do
|
||
desc "Load empty demo dataset (no financial data)"
|
||
task empty: :environment do
|
||
start = Time.now
|
||
puts "🚀 Loading EMPTY demo data…"
|
||
|
||
Demo::Generator.new.generate_empty_data!
|
||
|
||
puts "✅ Done in #{(Time.now - start).round(2)}s"
|
||
end
|
||
|
||
desc "Load new-user demo dataset (family created but not onboarded)"
|
||
task new_user: :environment do
|
||
start = Time.now
|
||
puts "🚀 Loading NEW-USER demo data…"
|
||
|
||
Demo::Generator.new.generate_new_user_data!
|
||
|
||
puts "✅ Done in #{(Time.now - start).round(2)}s"
|
||
end
|
||
|
||
desc "Load full realistic demo dataset"
|
||
task default: :environment do
|
||
start = Time.now
|
||
seed = ENV.fetch("SEED", Random.new_seed)
|
||
puts "🚀 Loading FULL demo data (seed=#{seed})…"
|
||
|
||
generator = Demo::Generator.new(seed: seed)
|
||
generator.generate_default_data!
|
||
|
||
validate_demo_data!
|
||
|
||
elapsed = Time.now - start
|
||
puts "🎉 Demo data ready in #{elapsed.round(2)}s"
|
||
end
|
||
|
||
# ---------------------------------------------------------------------------
|
||
# Validation helpers
|
||
# ---------------------------------------------------------------------------
|
||
def validate_demo_data!
|
||
total_entries = Entry.count
|
||
trade_entries = Entry.where(entryable_type: "Trade").count
|
||
categorized_txn = Transaction.joins(:category).count
|
||
txn_total = Transaction.count
|
||
|
||
coverage = ((categorized_txn.to_f / txn_total) * 100).round(1)
|
||
|
||
puts "\n📊 Validation Summary".ljust(40, "-")
|
||
puts "Entries total: #{total_entries}"
|
||
puts "Trade entries: #{trade_entries} (#{trade_entries.between?(500, 1000) ? '✅' : '❌'})"
|
||
puts "Txn categorization: #{coverage}% (>=75% ✅)"
|
||
|
||
unless total_entries.between?(8_000, 12_000)
|
||
raise "Total entries #{total_entries} outside 8k–12k range"
|
||
end
|
||
unless trade_entries.between?(500, 1000)
|
||
raise "Trade entries #{trade_entries} outside 500–1 000 range"
|
||
end
|
||
unless coverage >= 75
|
||
raise "Categorization coverage below 75%"
|
||
end
|
||
end
|
||
end
|