Sha256: 8885f1d038ce97fb35de9da7fe2be159909356ab72de0529418c167492145245
Contents?: true
Size: 786 Bytes
Versions: 39
Compression:
Stored size: 786 Bytes
Contents
module Dorsale module BillingMachine module SmallData class FilterStrategyByTimePeriod < ::Dorsale::SmallData::FilterStrategy def do_apply query if query.model.attribute_names.include?("day") field = :day else field = :date end criteria = "#{query.model.table_name}.#{field}" if @value == "today" return query.where("#{criteria} >= ?", Date.today) elsif @value == "week" return query.where("#{criteria} >= ?", Date.today.at_beginning_of_week) elsif @value == "month" return query.where("#{criteria} >= ?", Date.today.at_beginning_of_month) else return query end end end end end end
Version data entries
39 entries across 39 versions & 1 rubygems