lib/voteable_mongoid/voteable/voting.rb in voteable_mongoid-0.7.3 vs lib/voteable_mongoid/voteable/voting.rb in voteable_mongoid-0.7.4

- old
+ new

@@ -76,14 +76,15 @@ 'votes.up' => { '$ne' => options[:voter_id] }, 'votes.down' => { '$ne' => options[:voter_id] } }, { # then update '$push' => { positive_voter_ids => options[:voter_id] }, - '$inc' => { + '$inc' => { 'votes.count' => +1, positive_votes_count => +1, - 'votes.point' => options[:voteable][options[:value]] } + 'votes.point' => options[:voteable][options[:value]] + } } end def revote_query_and_update(options) @@ -102,11 +103,13 @@ end return { # Validate voter_id did a vote with value for votee_id :_id => options[:votee_id], - positive_voter_ids => { '$ne' => options[:voter_id] }, + # Can skip $ne validation since creating a new vote + # already warranty that a voter can vote one only + # positive_voter_ids => { '$ne' => options[:voter_id] }, negative_voter_ids => options[:voter_id] }, { # then update '$pull' => { negative_voter_ids => options[:voter_id] }, '$push' => { positive_voter_ids => options[:voter_id] }, @@ -131,10 +134,12 @@ end return { :_id => options[:votee_id], # Validate if voter_id did a vote with value for votee_id - negative_voter_ids => { '$ne' => options[:voter_id] }, + # Can skip $ne validation since creating a new vote + # already warranty that a voter can vote one only + # negative_voter_ids => { '$ne' => options[:voter_id] }, positive_voter_ids => options[:voter_id] }, { # then update '$pull' => { positive_voter_ids => options[:voter_id] }, '$inc' => {