Module: TimeFrameFilter

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

Instance Method Summary collapse

Instance Method Details

#by_timeframe(items, with_namespace_cte: false) ⇒ Object



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

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

  start_date = params[:start_date].to_date
  end_date = params[:end_date].to_date

  if with_namespace_cte
    items.within_timeframe(start_date, end_date, with_namespace_cte: true)
  else
    items.within_timeframe(start_date, end_date)
  end
rescue ArgumentError
  items
end

#containing_date(items) ⇒ Object



19
20
21
22
23
24
# File 'app/finders/concerns/time_frame_filter.rb', line 19

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

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