mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 21:29:38 +02:00
26 lines
634 B
Ruby
26 lines
634 B
Ruby
|
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,
|
||
|
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
|