Sha256: 016e716733a35752d7b2a4c94b1622db3861022a4f578d4e20213496a7bfaadd

Contents?: true

Size: 742 Bytes

Versions: 2

Compression:

Stored size: 742 Bytes

Contents

module Workarea
  module Api
    module Admin
      module DateFiltering
        extend ActiveSupport::Concern
        included do
          scope :by_updated_at, ->(starts_at:, ends_at:) do
            query = criteria
            query = query.where(:updated_at.gte => starts_at) unless starts_at.nil?
            query = query.where(:updated_at.lte => ends_at) unless ends_at.nil?
            query
          end

          scope :by_created_at, ->(starts_at:, ends_at:) do
            query = criteria
            query = query.where(:created_at.gte => starts_at) unless starts_at.nil?
            query = query.where(:created_at.lte => ends_at) unless ends_at.nil?
            query
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
workarea-api-4.5.6 admin/app/models/workarea/api/admin/date_filtering.rb
workarea-api-admin-4.5.6 app/models/workarea/api/admin/date_filtering.rb