Module: WorkUnit::Finders

Included in:
WorkUnit
Defined in:
app/models/work_unit/finders.rb

Instance Method Summary collapse

Instance Method Details

#ctoObject



51
52
53
# File 'app/models/work_unit/finders.rb', line 51

def cto
  where(:hours_type => 'CTO')
end

#except_client(client) ⇒ Object



23
24
25
# File 'app/models/work_unit/finders.rb', line 23

def except_client(client)
  joins({:ticket => {:project => [:client]}}).where("clients.id <> ?", client.id)
end

#for_client(client) ⇒ Object



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

def for_client(client)
  joins({:ticket => {:project => [:client]}}).where("clients.id = ?", client.id)
end

#for_project(project) ⇒ Object



27
28
29
# File 'app/models/work_unit/finders.rb', line 27

def for_project(project)
  joins({:ticket => [:project]}).where("projects.id = ?", project.id)
end

#for_ticket(ticket) ⇒ Object



31
32
33
# File 'app/models/work_unit/finders.rb', line 31

def for_ticket(ticket)
  where(:ticket_id => ticket.id)
end

#for_user(user) ⇒ Object



35
36
37
# File 'app/models/work_unit/finders.rb', line 35

def for_user(user)
  where(:user_id => user.id)
end

#for_users(users) ⇒ Object



39
40
41
# File 'app/models/work_unit/finders.rb', line 39

def for_users(users)
  where("user_id IN (?)", users.map{|user| user.id})
end

#hours_typesObject



3
4
5
# File 'app/models/work_unit/finders.rb', line 3

def hours_types
  ['Normal', 'Overtime', 'CTO', 'PTO']
end

#normalObject



59
60
61
# File 'app/models/work_unit/finders.rb', line 59

def normal
  where(:hours_type => 'Normal')
end

#not_invoicedObject



15
16
17
# File 'app/models/work_unit/finders.rb', line 15

def not_invoiced
  where(:invoiced => [nil, ''])
end

#on_estimated_ticketObject



63
64
65
# File 'app/models/work_unit/finders.rb', line 63

def on_estimated_ticket
   joins(:ticket).where("tickets.estimated_hours IS NOT NULL AND tickets.estimated_hours > 0")
end

#overtimeObject



55
56
57
# File 'app/models/work_unit/finders.rb', line 55

def overtime
  where(:hours_type => 'Overtime')
end

#ptoObject



47
48
49
# File 'app/models/work_unit/finders.rb', line 47

def pto
  where(:hours_type => 'PTO')
end

#scheduled_between(start_time, end_time) ⇒ Object



7
8
9
# File 'app/models/work_unit/finders.rb', line 7

def scheduled_between(start_time, end_time)
  where('scheduled_at BETWEEN ? AND ?', start_time, end_time)
end

#sort_by_scheduled_atObject



43
44
45
# File 'app/models/work_unit/finders.rb', line 43

def sort_by_scheduled_at
  order('scheduled_at DESC')
end

#unpaidObject



11
12
13
# File 'app/models/work_unit/finders.rb', line 11

def unpaid
  where(:paid => [nil, ''])
end