Class: MilestonesFinder

Inherits:
Object
  • Object
show all
Includes:
FinderMethods, TimeFrameFilter
Defined in:
app/finders/milestones_finder.rb

Overview

Search for milestones

params - Hash

ids - filters by id.
project_ids: Array of project ids or single project id or ActiveRecord relation.
group_ids: Array of group ids or single group id or ActiveRecord relation.
order - Orders by field default due date asc.
title - filter by title.
state - filters by state.
start_date & end_date - filters by timeframe (see TimeFrameFilter)
containing_date - filters by point in time (see TimeFrameFilter)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TimeFrameFilter

#by_timeframe, #containing_date

Methods included from FinderMethods

#find, #find_by, #find_by!

Constructor Details

#initialize(params = {}) ⇒ MilestonesFinder

Returns a new instance of MilestonesFinder.


21
22
23
# File 'app/finders/milestones_finder.rb', line 21

def initialize(params = {})
  @params = params
end

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params


19
20
21
# File 'app/finders/milestones_finder.rb', line 19

def params
  @params
end

Instance Method Details

#executeObject


25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/finders/milestones_finder.rb', line 25

def execute
  items = Milestone.all
  items = by_ids(items)
  items = by_groups_and_projects(items)
  items = by_title(items)
  items = by_search_title(items)
  items = by_state(items)
  items = by_timeframe(items)
  items = containing_date(items)

  order(items)
end