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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from TimeFrameFilter

#by_timeframe

Methods included from FinderMethods

#find, #find_by, #find_by!

Constructor Details

#initialize(params = {}) ⇒ MilestonesFinder

Returns a new instance of MilestonesFinder.


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

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

Instance Attribute Details

#paramsObject (readonly)

Returns the value of attribute params


17
18
19
# File 'app/finders/milestones_finder.rb', line 17

def params
  @params
end

Instance Method Details

#executeObject


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

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)

  order(items)
end