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

Handle stale syncs (#2257)
Some checks are pending
Publish Docker image / ci (push) Waiting to run
Publish Docker image / Build docker image (push) Blocked by required conditions

* Handle stale syncs

* Use `visible` sync logic in sidebar groups
This commit is contained in:
Zach Gollwitzer 2025-05-17 18:28:21 -04:00 committed by GitHub
parent 10f255a9a9
commit 9f13b5bb83
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 79 additions and 7 deletions

View file

@ -10,8 +10,19 @@ module Syncable
end
def sync_later(parent_sync: nil, window_start_date: nil, window_end_date: nil)
new_sync = syncs.create!(parent: parent_sync, window_start_date: window_start_date, window_end_date: window_end_date)
SyncJob.perform_later(new_sync)
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!)
new_sync = syncs.create!(
parent: parent_sync,
window_start_date: window_start_date,
window_end_date: window_end_date
)
SyncJob.perform_later(new_sync)
end
end
def perform_sync(sync)