1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-08 23:15:24 +02:00

Leftover cleanup from prior PR

This commit is contained in:
Zach Gollwitzer 2025-06-15 05:47:38 -04:00
parent 84b2426e54
commit c695941f81
2 changed files with 54 additions and 68 deletions

View file

@ -29,35 +29,6 @@ class Demo::Generator
# Expose the seed so callers can reproduce a run if necessary. # Expose the seed so callers can reproduce a run if necessary.
attr_reader :seed attr_reader :seed
# ---------------------------------------------------------------------------
# Performance helpers
# ---------------------------------------------------------------------------
private
# Simple timing helper. Pass a descriptive label and a block; the runtime
# will be printed automatically when the block completes.
# If max_seconds is provided, raise RuntimeError when the block exceeds that
# duration. Useful to keep CI/dev machines honest about demo-data perf.
def with_timing(label, max_seconds: nil)
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
result = yield
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
puts "⏱️ #{label} completed in #{duration.round(2)}s"
if max_seconds && duration > max_seconds
raise "Demo::Generator ##{label} exceeded #{max_seconds}s (#{duration.round(2)}s)"
end
result
end
# Override Kernel#rand so *all* `rand` calls inside this instance (including
# those already present in the file) are routed through the seeded PRNG.
def rand(*args)
@rng.rand(*args)
end
# Generate empty family - no financial data # Generate empty family - no financial data
def generate_empty_data!(skip_clear: false) def generate_empty_data!(skip_clear: false)
with_timing(__method__) do with_timing(__method__) do
@ -112,13 +83,33 @@ class Demo::Generator
end end
end end
# Multi-currency support (keeping existing functionality) private
def generate_multi_currency_data!(family_names)
with_timing(__method__) do # Simple timing helper. Pass a descriptive label and a block; the runtime
generate_for_scenario(:multi_currency, family_names) # will be printed automatically when the block completes.
# If max_seconds is provided, raise RuntimeError when the block exceeds that
# duration. Useful to keep CI/dev machines honest about demo-data perf.
def with_timing(label, max_seconds: nil)
start = Process.clock_gettime(Process::CLOCK_MONOTONIC)
result = yield
duration = Process.clock_gettime(Process::CLOCK_MONOTONIC) - start
puts "⏱️ #{label} completed in #{duration.round(2)}s"
if max_seconds && duration > max_seconds
raise "Demo::Generator ##{label} exceeded #{max_seconds}s (#{duration.round(2)}s)"
end end
result
end end
# Override Kernel#rand so *all* `rand` calls inside this instance (including
# those already present in the file) are routed through the seeded PRNG.
def rand(*args)
@rng.rand(*args)
end
def clear_all_data! def clear_all_data!
family_count = Family.count family_count = Family.count
if family_count > 50 if family_count > 50
@ -1226,8 +1217,3 @@ class Demo::Generator
puts " ✅ Set property and vehicle valuations" puts " ✅ Set property and vehicle valuations"
end end
end end
# Expose public API after full class definition
Demo::Generator.public_instance_methods.include?(:generate_default_data!) or Demo::Generator.class_eval do
public :generate_empty_data!, :generate_new_user_data!, :generate_default_data!, :generate_multi_currency_data!
end