mirror of
https://github.com/we-promise/sure.git
synced 2026-07-12 04:45:19 +00:00
perf(dashboard): streamline investment activity totals (#2257)
* perf(dashboard): streamline investment activity totals * fix(dashboard): skip empty investment totals cache writes Short-circuit empty investment account totals before cache fetch and move the new SQL query capture regression helper into test/support. * refactor(dashboard): address review on investment totals query - Drop defensive ArgumentError guards in InvestmentStatement::Totals#initialize. The sole caller (totals_query) always passes correct types, and the empty_result early-return already handles the zero-accounts case. - Remove the redundant accounts JOIN and its family_id/status filters from the aggregation SQL. account_ids is already scoped to the family's visible (draft/active) investment accounts, so the join back to accounts is unnecessary work in the query plan. Drop the now-unused family_id param. - Add a regression assertion that the aggregate no longer joins accounts.
This commit is contained in:
17
test/support/sql_query_capture.rb
Normal file
17
test/support/sql_query_capture.rb
Normal file
@@ -0,0 +1,17 @@
|
||||
module SqlQueryCapture
|
||||
def capture_sql_queries
|
||||
queries = []
|
||||
callback = lambda do |_name, _started, _finished, _unique_id, payload|
|
||||
next if payload[:cached]
|
||||
next if %w[SCHEMA TRANSACTION].include?(payload[:name])
|
||||
|
||||
queries << payload[:sql].squish
|
||||
end
|
||||
|
||||
ActiveSupport::Notifications.subscribed(callback, "sql.active_record") do
|
||||
yield
|
||||
end
|
||||
|
||||
queries
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user