mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
Refactor sparkline error handling and improve series pre-loading
- Added pre-loading of series in AccountableSparklinesController and AccountsController to catch errors before rendering. - Updated the accounts view to use the pre-loaded sparkline series variable. - Adjusted the test for graceful handling of errors in the sparkline series method. This enhances the robustness of the sparkline feature and improves error visibility in the UI.
This commit is contained in:
@@ -2,6 +2,7 @@ class AccountableSparklinesController < ApplicationController
|
||||
def show
|
||||
@accountable = Accountable.from_type(params[:accountable_type]&.classify)
|
||||
|
||||
# Pre-load the series to catch any errors before rendering
|
||||
@series = Rails.cache.fetch(cache_key) do
|
||||
account_ids = family.accounts.active.where(accountable_type: @accountable.name).pluck(:id)
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ class AccountsController < ApplicationController
|
||||
end
|
||||
|
||||
def sparkline
|
||||
# Pre-load the sparkline series to catch any errors before rendering
|
||||
@sparkline_series = @account.sparkline_series
|
||||
render layout: false
|
||||
rescue => e
|
||||
Rails.logger.error "Sparkline error for account #{@account.id}: #{e.message}"
|
||||
|
||||
Reference in New Issue
Block a user