Class: SpreeCmCommissioner::VoteCounters::PerContestantCounter

Inherits:
Base
  • Object
show all
Defined in:
app/services/spree_cm_commissioner/vote_counters/per_contestant_counter.rb

Constant Summary

Constants inherited from Base

Base::REDIS_KEY_TTL

Instance Attribute Summary

Attributes inherited from Base

#voting_session_id

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from SpreeCmCommissioner::VoteCounters::Base

Instance Method Details

#callObject



14
15
16
17
18
19
20
21
22
# File 'app/services/spree_cm_commissioner/vote_counters/per_contestant_counter.rb', line 14

def call
  ids = contestant_ids
  return {} if ids.empty?

  with_redis do |redis|
    values = redis.mget(*ids.map { |id| vote_key(id) })
    ids.zip(values).to_h { |id, v| [id, v.to_i] }
  end
end