mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 05:25:24 +02:00
Implement auto family syncs on login (#1021)
This commit is contained in:
parent
c8590d53ba
commit
ef4be7948a
11 changed files with 59 additions and 9 deletions
|
@ -105,6 +105,16 @@ class Family < ApplicationRecord
|
|||
end
|
||||
|
||||
def sync(start_date: nil)
|
||||
accounts.active.sync(start_date: start_date)
|
||||
accounts.active.each do |account|
|
||||
if account.needs_sync?
|
||||
account.sync_later(start_date: start_date || account.last_sync_date)
|
||||
end
|
||||
end
|
||||
|
||||
update! last_synced_at: Time.now
|
||||
end
|
||||
|
||||
def needs_sync?
|
||||
last_synced_at.nil? || last_synced_at.to_date < Date.current
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue