Class: SpreeCmCommissioner::MaintenanceTasks::VotingSession
- Inherits:
-
SpreeCmCommissioner::MaintenanceTask
- Object
- Spree::Base
- Base
- SpreeCmCommissioner::MaintenanceTask
- SpreeCmCommissioner::MaintenanceTasks::VotingSession
- Defined in:
- app/models/spree_cm_commissioner/maintenance_tasks/voting_session.rb
Constant Summary
Constants inherited from SpreeCmCommissioner::MaintenanceTask
SpreeCmCommissioner::MaintenanceTask::MAX_ATTEMPTS
Instance Method Summary collapse
- #maintain ⇒ Object
-
#rebuild_ttl ⇒ Object
For closed sessions, or one that never opened voting, use the fixed 24h constant — vote_close_at is either in the past or blank, so the dynamic formula would produce a TTL shorter than intended (or blow up on nil).
Methods inherited from SpreeCmCommissioner::MaintenanceTask
Instance Method Details
#maintain ⇒ Object
19 20 21 22 23 24 |
# File 'app/models/spree_cm_commissioner/maintenance_tasks/voting_session.rb', line 19 def maintain ttl = rebuild_ttl SpreeCmCommissioner::VoteCounters::RebuildFromDb.call(voting_session_id: maintainable.id, ttl: ttl) SpreeCmCommissioner::VoteCounters::AuditCounters.call(voting_session_id: maintainable.id) SpreeCmCommissioner::VoteCounters::SnapshotToDb.call(voting_session_id: maintainable.id) end |
#rebuild_ttl ⇒ Object
For closed sessions, or one that never opened voting, use the fixed 24h constant — vote_close_at is either in the past or blank, so the dynamic formula would produce a TTL shorter than intended (or blow up on nil). For active sessions use vote_close_at + 24h buffer (same formula as Increment).
30 31 32 33 34 |
# File 'app/models/spree_cm_commissioner/maintenance_tasks/voting_session.rb', line 30 def rebuild_ttl return SpreeCmCommissioner::VoteCounters::Base::REDIS_KEY_TTL if maintainable.closed? || maintainable.vote_close_at.blank? [(maintainable.vote_close_at - Time.current).to_i + 1.day.to_i, 1].max end |