mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 05:09:38 +02:00
Account Sync should happen at login, 1x per day, OR on-demand (#594)
* Add last_sync_date to accounts table * Always sync Account after Valuation or Transaction creation, update, or deletion. Skip sync if user clicks "sync" button without changing anything * Sync user accounts daily based on last_login_at
This commit is contained in:
parent
4f0b2de4ef
commit
315c4bf1ec
8 changed files with 48 additions and 8 deletions
|
@ -20,7 +20,7 @@ class AccountsController < ApplicationController
|
|||
def update
|
||||
if @account.update(account_params.except(:accountable_type))
|
||||
|
||||
@account.sync_later if account_params[:is_active] == "1"
|
||||
@account.sync_later if account_params[:is_active] == "1" && @account.can_sync?
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to accounts_path, notice: t(".success") }
|
||||
|
@ -53,15 +53,12 @@ class AccountsController < ApplicationController
|
|||
end
|
||||
|
||||
def sync
|
||||
@account.sync_later
|
||||
@account.sync_later if @account.can_sync?
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to account_path(@account), notice: t(".success") }
|
||||
format.turbo_stream do
|
||||
render turbo_stream: [
|
||||
turbo_stream.append("notification-tray", partial: "shared/notification", locals: { type: "success", content: t(".success") }),
|
||||
turbo_stream.replace("sync_message", partial: "accounts/sync_message", locals: { is_syncing: true })
|
||||
]
|
||||
render turbo_stream: turbo_stream.append("notification-tray", partial: "shared/notification", locals: { type: "success", content: t(".success") })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue