1
0
Fork 0
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:
Mattia 2024-04-04 23:00:12 +02:00 committed by GitHub
parent 4f0b2de4ef
commit 315c4bf1ec
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 48 additions and 8 deletions

View file

@ -2,6 +2,8 @@ class ApplicationController < ActionController::Base
include Authentication
include Pagy::Backend
before_action :sync_accounts
default_form_builder ApplicationFormBuilder
# Only allow modern browsers supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has.
@ -13,4 +15,12 @@ class ApplicationController < ActionController::Base
ENV["HOSTED"] == "true"
end
helper_method :hosted_app?
def sync_accounts
return if Current.user.blank?
if Current.user.last_login_at.nil? || Current.user.last_login_at.before?(Date.current.beginning_of_day)
Current.family.sync_accounts
end
end
end