Johnmcaliley - added code climate and changes to contributors.
This commit is contained in:
Antonio C Nalesso Moreira 2013-10-28 17:54:29 +00:00
commit fb535b29f7
2 changed files with 15 additions and 20 deletions

View File

@ -1,6 +1,7 @@
![Impressionist Logo](https://github.com/charlotte-ruby/impressionist/raw/master/logo.png)
[![Build Status](https://secure.travis-ci.org/charlotte-ruby/impressionist.png?branch=master)](http://travis-ci.org/charlotte-ruby/impressionist)
[![Code Climate](https://codeclimate.com/github/charlotte-ruby/impressionist.png)](https://codeclimate.com/github/charlotte-ruby/impressionist)
impressionist
=============
@ -224,9 +225,10 @@ Want to run the tests? Ok mummy
Contributors
------------
* [johnmcaliley](https://github.com/johnmcaliley)
* [johnmcaliley - creator](https://github.com/johnmcaliley)
* [Antonio C Nalesso - maintainer](https://github.com/nbit001)
* [coryschires](https://github.com/coryschires)
* [georgmittendorfer](https://github.com/georgmittendorfer)
* [Antonio C Nalesso](https://github.com/nbit001)
Copyright (c) 2011 John McAliley. See LICENSE.txt for further details.

View File

@ -4,28 +4,21 @@ module Impressionist
# extends AS::Concern
include Impressionist::IsImpressionable
## TODO: Make it readable
# Overides impressionist_count in order to provied
# mongoid compability
# Overides impressionist_count in order to provide 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])
# Uses these options as defaults unless overridden in options hash
options.reverse_merge!(:filter => :request_hash, :start_date => nil, :end_date => Time.now)
filter = options[:filter]
# If a start_date is provided, finds impressions between then and the end_date.
# Otherwise returns all impressions
imps = options[:start_date].blank? ? impressions :
impressions.between(created_at: options[:start_date]..options[:end_date])
filter == :all ?
imps.count :
imps.where(filter.ne => nil).
distinct(filter).count
# Count all distinct impressions unless the :all filter is provided
distinct = options[:filter] != :all
distinct ? imps.where(filter.ne => nil).distinct(filter).count : imps.count
end
end