2020-02-05 12:09:15 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module TimeFrameFilter
|
|
|
|
def by_timeframe(items)
|
2021-01-11 09:10:46 +00:00
|
|
|
return items unless params[:start_date] && params[:end_date]
|
2020-02-05 12:09:15 +00:00
|
|
|
|
|
|
|
start_date = params[:start_date].to_date
|
|
|
|
end_date = params[:end_date].to_date
|
|
|
|
|
|
|
|
items.within_timeframe(start_date, end_date)
|
|
|
|
rescue ArgumentError
|
|
|
|
items
|
|
|
|
end
|
2020-10-14 03:08:32 +00:00
|
|
|
|
|
|
|
def containing_date(items)
|
|
|
|
return items unless params[:containing_date]
|
|
|
|
|
|
|
|
date = params[:containing_date].to_date
|
|
|
|
items.within_timeframe(date, date)
|
|
|
|
end
|
2020-02-05 12:09:15 +00:00
|
|
|
end
|