Class: SpreeCmCommissioner::VotingSessionFirestorePublishJob

Inherits:
ApplicationJob show all
Defined in:
app/jobs/spree_cm_commissioner/voting_session_firestore_publish_job.rb

Overview

Pushes a voting session's live state to Firestore off the request cycle, so an organizer pressing "Start Vote" never waits on a Firestore round-trip.

Takes an id rather than the record so a retry publishes the state as it is now, not as it was when the job was enqueued — a rapid start/pause/stop sequence must not have a stale retry overwrite the current state.

Instance Method Summary collapse

Methods included from ApplicationJobDecorator

handle_deserialization_error, prepended

Instance Method Details

#perform(voting_session_id) ⇒ Object



11
12
13
14
15
16
# File 'app/jobs/spree_cm_commissioner/voting_session_firestore_publish_job.rb', line 11

def perform(voting_session_id)
  voting_session = SpreeCmCommissioner::VotingSession.find_by(id: voting_session_id)
  return if voting_session.nil?

  SpreeCmCommissioner::VotingSessions::PublishToFirestore.call(voting_session: voting_session)
end