Merge branch 'master' of https://github.com/charlotte-ruby/impressionist
Johnmcaliley - added code climate and changes to contributors.
This commit is contained in:
commit
fb535b29f7
|
@ -1,6 +1,7 @@
|
||||||
![Impressionist Logo](https://github.com/charlotte-ruby/impressionist/raw/master/logo.png)
|
![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)
|
[![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
|
impressionist
|
||||||
=============
|
=============
|
||||||
|
@ -224,9 +225,10 @@ Want to run the tests? Ok mummy
|
||||||
|
|
||||||
Contributors
|
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)
|
* [coryschires](https://github.com/coryschires)
|
||||||
* [georgmittendorfer](https://github.com/georgmittendorfer)
|
* [georgmittendorfer](https://github.com/georgmittendorfer)
|
||||||
* [Antonio C Nalesso](https://github.com/nbit001)
|
|
||||||
|
|
||||||
Copyright (c) 2011 John McAliley. See LICENSE.txt for further details.
|
Copyright (c) 2011 John McAliley. See LICENSE.txt for further details.
|
||||||
|
|
|
@ -4,28 +4,21 @@ module Impressionist
|
||||||
# extends AS::Concern
|
# extends AS::Concern
|
||||||
include Impressionist::IsImpressionable
|
include Impressionist::IsImpressionable
|
||||||
|
|
||||||
## TODO: Make it readable
|
# Overides impressionist_count in order to provide mongoid compability
|
||||||
|
|
||||||
# Overides impressionist_count in order to provied
|
|
||||||
# mongoid compability
|
|
||||||
def impressionist_count(options={})
|
def impressionist_count(options={})
|
||||||
options.
|
|
||||||
reverse_merge!(
|
|
||||||
:filter=>:request_hash,
|
|
||||||
:start_date=>nil,
|
|
||||||
:end_date=>Time.now)
|
|
||||||
|
|
||||||
imps = options[:start_date].blank? ?
|
# Uses these options as defaults unless overridden in options hash
|
||||||
impressions :
|
options.reverse_merge!(:filter => :request_hash, :start_date => nil, :end_date => Time.now)
|
||||||
impressions.
|
|
||||||
between(created_at: options[:start_date]..options[:end_date])
|
|
||||||
|
|
||||||
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 :
|
# Count all distinct impressions unless the :all filter is provided
|
||||||
imps.where(filter.ne => nil).
|
distinct = options[:filter] != :all
|
||||||
distinct(filter).count
|
distinct ? imps.where(filter.ne => nil).distinct(filter).count : imps.count
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue