Skip to content

Commit

Permalink
Merge pull request #414 from alphagov/move-counts-outside-lock
Browse files Browse the repository at this point in the history
Move signature count updates outside the lock
  • Loading branch information
alanth committed Dec 9, 2015
2 parents 9ee4d61 + ab02322 commit 248d561
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/models/signature.rb
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,11 @@ def unsubscribed?
end

def validate!
update_signature_counts = false

with_lock do
if pending?
update_signature_counts = true
petition.validate_creator_signature! unless creator?

update_columns(
Expand All @@ -112,12 +115,14 @@ def validate!
validated_at: Time.current,
updated_at: Time.current
)

#ConstituencyPetitionJournal.record_new_signature_for(self)
#CountryPetitionJournal.record_new_signature_for(self)
petition.increment_signature_count!
end
end

if update_signature_counts
#ConstituencyPetitionJournal.record_new_signature_for(self)
#CountryPetitionJournal.record_new_signature_for(self)
petition.increment_signature_count!
end
end

def mark_seen_signed_confirmation_page!
Expand Down

0 comments on commit 248d561

Please sign in to comment.