lib/voteable_mongoid/voteable/tasks.rb in voteable_mongoid-0.7.3 vs lib/voteable_mongoid/voteable/tasks.rb in voteable_mongoid-0.7.4
- old
+ new
@@ -57,11 +57,11 @@
'up' => up_voter_ids,
'down' => down_voter_ids,
'up_count' => up_count,
'down_count' => down_count,
'count' => up_count + down_count,
- 'point' => voteable[:up]*up_count + voteable[:down]*down_count
+ 'point' => voteable[:up].to_i*up_count + voteable[:down].to_i*down_count
}
},
'$unset' => {
'up_voter_ids' => true,
'down_voter_ids' => true,
@@ -92,11 +92,11 @@
doc.update_attributes(
'votes.up_count' => up_count,
'votes.down_count' => down_count,
'votes.count' => up_count + down_count,
- 'votes.point' => voteable[:up]*up_count + voteable[:down]*down_count
+ 'votes.point' => voteable[:up].to_i*up_count + voteable[:down].to_i*down_count
)
end
def self.update_parent_stats(log)
@@ -124,10 +124,10 @@
down_count = doc.down_voter_ids.length
return if up_count == 0 && down_count == 0
inc_options = {
- 'votes.point' => voteable[:up]*up_count + voteable[:down]*down_count
+ 'votes.point' => voteable[:up].to_i*up_count + voteable[:down].to_i*down_count
}
unless voteable[:update_counters] == false
inc_options.merge!(
'votes.count' => up_count + down_count,
\ No newline at end of file