Sha256: 5f8e102032a68e1df723516663a9bb5ad8df31fcd5c1d00d4b39c8995a0bf21f
Contents?: true
Size: 778 Bytes
Versions: 2
Compression:
Stored size: 778 Bytes
Contents
module ByStar module Calculations module Count def count_by_year(field=nil, year=Time.zone.now.year, options={}, &block) db_field = options.delete(:field) scoped_by(block) do count(field, { :conditions => conditions_for_range(start_of_year(year), end_of_year(year), db_field) }.reverse_merge!(options)) end end def count_by_month(field=nil, month=Time.now.month, options={}, &block) db_field = options.delete(:field) year, month = work_out_month(month, options.delete(:year)) scoped_by(block) do count(field, { :conditions => conditions_for_range(start_of_month(month, year), end_of_month(month, year), db_field) }.reverse_merge!(options)) end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
by_star-0.6.3 | lib/calculations/count.rb |
by_star-0.6.2 | lib/calculations/count.rb |