mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 05:25:24 +02:00
perf(transactions): add kind
to Transaction
model and remove expensive Transfer joins in aggregations (#2388)
* add kind to transaction model * Basic transfer creator * Fix method naming conflict * Creator form pattern * Remove stale methods * Tweak migration * Remove BaseQuery, write entire query in each class for clarity * Query optimizations * Remove unused exchange rate query lines * Remove temporary cache-warming strategy * Fix test * Update transaction search * Decouple transactions endpoint from IncomeStatement * Clean up transactions controller * Update cursor rules * Cleanup comments, logic in search * Fix totals logic on transactions view * Fix pagination * Optimize search totals query * Default to last 30 days on transactions page if no filters * Decouple transactions list from transfer details * Revert transfer route * Migration reset * Bundle update * Fix matching logic, tests * Remove unused code
This commit is contained in:
parent
7aca5a2277
commit
1aae00f586
49 changed files with 1749 additions and 705 deletions
|
@ -91,6 +91,7 @@ class Family < ApplicationRecord
|
|||
entries.order(:date).first&.date || Date.current
|
||||
end
|
||||
|
||||
# Used for invalidating family / balance sheet related aggregation queries
|
||||
def build_cache_key(key, invalidate_on_data_updates: false)
|
||||
# Our data sync process updates this timestamp whenever any family account successfully completes a data update.
|
||||
# By including it in the cache key, we can expire caches every time family account data changes.
|
||||
|
@ -103,6 +104,14 @@ class Family < ApplicationRecord
|
|||
].compact.join("_")
|
||||
end
|
||||
|
||||
# Used for invalidating entry related aggregation queries
|
||||
def entries_cache_version
|
||||
@entries_cache_version ||= begin
|
||||
ts = entries.maximum(:updated_at)
|
||||
ts.present? ? ts.to_i : 0
|
||||
end
|
||||
end
|
||||
|
||||
def self_hoster?
|
||||
Rails.application.config.app_mode.self_hosted?
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue