From 3d23031a3134c93292d73ad966d0e0e5eb34f878 Mon Sep 17 00:00:00 2001 From: Antonio C Nalesso Moreira Date: Fri, 6 Sep 2013 02:25:34 +0100 Subject: [PATCH] removed sqlite3 dependency as it causes heroku to fail [ci skip] --- impressionist.gemspec | 1 - .../mongoid/impressionist/impressionable.rb | 19 ++++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) 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