Module: TimeFrameFilter

Included in:
MilestonesFinder
Defined in:
app/finders/concerns/time_frame_filter.rb

Instance Method Summary collapse

Instance Method Details

#by_timeframe(items) ⇒ Object



4
5
6
7
8
9
10
11
12
13
# File 'app/finders/concerns/time_frame_filter.rb', line 4

def by_timeframe(items)
  return items unless params[:start_date] && params[:end_date]

  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

#containing_date(items) ⇒ Object



15
16
17
18
19
20
# File 'app/finders/concerns/time_frame_filter.rb', line 15

def containing_date(items)
  return items unless params[:containing_date]

  date = params[:containing_date].to_date
  items.within_timeframe(date, date)
end