Class: SpreeCmCommissioner::VotingSessions::AutoOpen
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::VotingSessions::AutoOpen
- Includes:
- Spree::ServiceModule::Base
- Defined in:
- app/services/spree_cm_commissioner/voting_sessions/auto_open.rb
Overview
Opens voting the moment a pre-set vote_open_at arrives, for the two cases that never go through #start_vote!:
already enabled
Called by VotingSessionAutoOpenJob, enqueued from VotingSessions::ScheduleVoteWindowJobs with wait_until: vote_open_at.
Instance Method Summary collapse
Instance Method Details
#call(voting_session:) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/services/spree_cm_commissioner/voting_sessions/auto_open.rb', line 23 def call(voting_session:) # vote_open_at may have moved since this was scheduled (an organizer editing the window # again, or a restart). Only act once the window has genuinely arrived; otherwise the run # that matches the new vote_open_at will handle it. return success(:skipped) if voting_session.vote_open_at.present? && Time.current < voting_session.vote_open_at # Triggers VotingSessionTimingConcern's own after_commit callbacks on this same save, which # schedules VotingSessionAutoCloseJob for vote_close_at now that the session is enabled — # no need to enqueue it again here. voting_session.update!(status: :enabled) if voting_session.on_air? && voting_session.visible? SpreeCmCommissioner::VotingSessions::PublishToFirestore.call(voting_session: voting_session) end |