mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-18 20:59:39 +02:00
* Balance sheet cache layer with cache-busting * Update family cache timestamps during Sync * Less blocking sync loaders * Consolidate family data caching key logic * Fix turbo stream broadcasts * Remove dev delay * Add back account group sorting
44 lines
1.1 KiB
Ruby
44 lines
1.1 KiB
Ruby
class AccountsController < ApplicationController
|
|
before_action :set_account, only: %i[sync chart sparkline]
|
|
include Periodable
|
|
|
|
def index
|
|
@manual_accounts = family.accounts.manual.alphabetically
|
|
@plaid_items = family.plaid_items.ordered
|
|
|
|
render layout: "settings"
|
|
end
|
|
|
|
def sync
|
|
unless @account.syncing?
|
|
@account.sync_later
|
|
end
|
|
|
|
redirect_to account_path(@account)
|
|
end
|
|
|
|
def chart
|
|
@chart_view = params[:chart_view] || "balance"
|
|
render layout: "application"
|
|
end
|
|
|
|
def sparkline
|
|
etag_key = @account.family.build_cache_key("#{@account.id}_sparkline", invalidate_on_data_updates: true)
|
|
|
|
# Short-circuit with 304 Not Modified when the client already has the latest version.
|
|
# We defer the expensive series computation until we know the content is stale.
|
|
if stale?(etag: etag_key, last_modified: @account.family.latest_sync_completed_at)
|
|
@sparkline_series = @account.sparkline_series
|
|
render layout: false
|
|
end
|
|
end
|
|
|
|
private
|
|
def family
|
|
Current.family
|
|
end
|
|
|
|
def set_account
|
|
@account = family.accounts.find(params[:id])
|
|
end
|
|
end
|