mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 05:25:24 +02:00
Tweak exception logging, sync stale behavior
This commit is contained in:
parent
9f13b5bb83
commit
29a8ac9d8a
6 changed files with 46 additions and 26 deletions
|
@ -11,17 +11,18 @@ module Syncable
|
|||
|
||||
def sync_later(parent_sync: nil, window_start_date: nil, window_end_date: nil)
|
||||
Sync.transaction do
|
||||
# Expire any previous in-flight syncs for this record that exceeded the
|
||||
# global staleness window.
|
||||
syncs.stale_candidates.find_each(&:mark_stale!)
|
||||
# Since we're scheduling a new sync, mark old syncs for this syncable as stale
|
||||
self.syncs.incomplete.find_each(&:mark_stale!)
|
||||
|
||||
new_sync = syncs.create!(
|
||||
new_sync = self.syncs.create!(
|
||||
parent: parent_sync,
|
||||
window_start_date: window_start_date,
|
||||
window_end_date: window_end_date
|
||||
)
|
||||
|
||||
SyncJob.perform_later(new_sync)
|
||||
|
||||
new_sync
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue