diff --git a/impressionist.gemspec b/impressionist.gemspec index 8bec8b6..3328ef6 100644 --- a/impressionist.gemspec +++ b/impressionist.gemspec @@ -30,7 +30,6 @@ Gem::Specification.new do |s| s.add_development_dependency 'rdoc', '>= 2.4.2' s.add_development_dependency 'rspec-rails' s.add_development_dependency 'simplecov' - s.add_development_dependency 'sqlite3' s.add_development_dependency 'systemu' s.add_development_dependency 'minitest' s.add_development_dependency 'minitest-rails' diff --git a/lib/impressionist/models/mongoid/impressionist/impressionable.rb b/lib/impressionist/models/mongoid/impressionist/impressionable.rb index 2bacfd1..c4ca3a8 100644 --- a/lib/impressionist/models/mongoid/impressionist/impressionable.rb +++ b/lib/impressionist/models/mongoid/impressionist/impressionable.rb @@ -9,10 +9,23 @@ module Impressionist # Overides impressionist_count in order to provied # mongoid compability 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. + 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]) + filter = options[:filter] - filter == :all ? imps.count : imps.where(filter.ne => nil).distinct(filter).count + + filter == :all ? + imps.count : + imps.where(filter.ne => nil). + distinct(filter).count end end