2025-02-21 11:57:59 -05:00
|
|
|
class AccountableSparklinesController < ApplicationController
|
|
|
|
def show
|
|
|
|
@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,
|
2025-05-06 09:25:49 -04:00
|
|
|
timezone: family.timezone,
|
2025-02-21 11:57:59 -05:00
|
|
|
favorable_direction: @accountable.favorable_direction
|
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
render layout: false
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def family
|
|
|
|
Current.family
|
|
|
|
end
|
|
|
|
|
|
|
|
def cache_key
|
|
|
|
family.build_cache_key("#{@accountable.name}_sparkline")
|
|
|
|
end
|
|
|
|
end
|