1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-08-04 21:15:19 +02:00

Tweak exception logging, sync stale behavior

This commit is contained in:
Zach Gollwitzer 2025-05-18 10:19:15 -04:00
parent 9f13b5bb83
commit 29a8ac9d8a
6 changed files with 46 additions and 26 deletions

View file

@ -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