Improve chart performance and gapfilling (#2306)

This commit is contained in:
Zach Gollwitzer
2025-05-25 20:40:18 -04:00
committed by GitHub
parent e1b81ef879
commit 6e202bd7ec
10 changed files with 382 additions and 196 deletions

View File

@@ -3,12 +3,17 @@ class AccountableSparklinesController < ApplicationController
@accountable = Accountable.from_type(params[:accountable_type]&.classify)
@series = Rails.cache.fetch(cache_key) do
family.accounts.active
.where(accountable_type: @accountable.name)
.balance_series(
currency: family.currency,
favorable_direction: @accountable.favorable_direction
)
account_ids = family.accounts.active.where(accountable_type: @accountable.name).pluck(:id)
builder = Balance::ChartSeriesBuilder.new(
account_ids: account_ids,
currency: family.currency,
period: Period.last_30_days,
favorable_direction: @accountable.favorable_direction,
interval: "1 day"
)
builder.balance_series
end
render layout: false