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

Version Path
dorsale-2.3.5 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.3.4 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.3.3 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.3.2 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.3.1 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.3.0 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.2.16 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.2.15 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.2.14 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.2.13 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.2.12 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.2.11 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.2.10 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.2.9 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.2.8 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.2.6 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.2.5 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.2.4 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.2.3 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb
dorsale-2.2.2 app/models/dorsale/billing_machine/small_data/filter_strategy_by_time_period.rb