Permalink
Browse files

Merge pull request #68 from FoboCasteR/fix-issue-60

Fix filter for mongoid (Fix #60)
  • Loading branch information...
2 parents 48b3819 + 7431129 commit 4a7532f69b85ec3f92c5c79e7de164bb4f368f80 @johnmcaliley johnmcaliley committed Apr 2, 2013
Showing with 3 additions and 2 deletions.
  1. +3 −2 lib/impressionist/models/mongoid/impressionist/impressionable.rb
@@ -37,7 +37,8 @@ def impressionable?
def impressionist_count(options={})
options.reverse_merge!(:filter=>:request_hash, :start_date=>nil, :end_date=>Time.now)
imps = options[:start_date].blank? ? impressions : impressions.between(created_at: options[:start_date]..options[:end_date])
- options[:filter] == :all ? imps.count : imps.where(options[:filter].ne => nil).count
+ filter = options[:filter]
+ filter == :all ? imps.count : imps.where(filter.ne => nil).distinct(filter).count
end
def update_impressionist_counter_cache
@@ -49,4 +50,4 @@ def update_impressionist_counter_cache
end
end
-end
+end

0 comments on commit 4a7532f

Please sign in to comment.