Skip to content
Extraits de code Groupes Projets
Valider 09c042aa rédigé par ThibG's avatar ThibG Validation de Eugen Rochko
Parcourir les fichiers

Handle StaleObjectError when retrieving polls (#10208)

parent 637c952c
Branches
Étiquettes
Aucune requête de fusion associée trouvée
...@@ -32,12 +32,17 @@ class ActivityPub::FetchRemotePollService < BaseService ...@@ -32,12 +32,17 @@ class ActivityPub::FetchRemotePollService < BaseService
# votes, so we need to remove them # votes, so we need to remove them
poll.votes.delete_all if latest_options != poll.options poll.votes.delete_all if latest_options != poll.options
poll.update!( begin
last_fetched_at: Time.now.utc, poll.update!(
expires_at: expires_at, last_fetched_at: Time.now.utc,
options: latest_options, expires_at: expires_at,
cached_tallies: items.map { |item| item.dig('replies', 'totalItems') || 0 } options: latest_options,
) cached_tallies: items.map { |item| item.dig('replies', 'totalItems') || 0 }
)
rescue ActiveRecord::StaleObjectError
poll.reload
retry
end
end end
private private
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter