mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 21:29:38 +02:00
Fix race condition in sync status monitor (#2412)
Move family timestamp update to after_commit callback to ensure database visibility before cache invalidation
This commit is contained in:
parent
cea49d5038
commit
72a0f87a9c
1 changed files with 6 additions and 1 deletions
|
@ -19,6 +19,8 @@ class Sync < ApplicationRecord
|
||||||
scope :incomplete, -> { where("syncs.status IN (?)", %w[pending syncing]) }
|
scope :incomplete, -> { where("syncs.status IN (?)", %w[pending syncing]) }
|
||||||
scope :visible, -> { incomplete.where("syncs.created_at > ?", VISIBLE_FOR.ago) }
|
scope :visible, -> { incomplete.where("syncs.created_at > ?", VISIBLE_FOR.ago) }
|
||||||
|
|
||||||
|
after_commit :update_family_sync_timestamp
|
||||||
|
|
||||||
validate :window_valid
|
validate :window_valid
|
||||||
|
|
||||||
# Sync state machine
|
# Sync state machine
|
||||||
|
@ -169,7 +171,6 @@ class Sync < ApplicationRecord
|
||||||
|
|
||||||
def handle_transition
|
def handle_transition
|
||||||
log_status_change
|
log_status_change
|
||||||
family.touch(:latest_sync_activity_at)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def handle_completion_transition
|
def handle_completion_transition
|
||||||
|
@ -182,6 +183,10 @@ class Sync < ApplicationRecord
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def update_family_sync_timestamp
|
||||||
|
family.touch(:latest_sync_activity_at)
|
||||||
|
end
|
||||||
|
|
||||||
def family
|
def family
|
||||||
if syncable.is_a?(Family)
|
if syncable.is_a?(Family)
|
||||||
syncable
|
syncable
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue