Module: WorkUnit::Finders
- Included in:
- WorkUnit
- Defined in:
- app/models/work_unit/finders.rb
Instance Method Summary collapse
- #cto ⇒ Object
- #except_client(client) ⇒ Object
- #for_client(client) ⇒ Object
- #for_project(project) ⇒ Object
- #for_ticket(ticket) ⇒ Object
- #for_user(user) ⇒ Object
- #for_users(users) ⇒ Object
- #hours_types ⇒ Object
- #normal ⇒ Object
- #not_invoiced ⇒ Object
- #on_estimated_ticket ⇒ Object
- #overtime ⇒ Object
- #pto ⇒ Object
- #scheduled_between(start_time, end_time) ⇒ Object
- #sort_by_scheduled_at ⇒ Object
- #unpaid ⇒ Object
Instance Method Details
#cto ⇒ Object
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_types ⇒ Object
3 4 5 |
# File 'app/models/work_unit/finders.rb', line 3 def hours_types ['Normal', 'Overtime', 'CTO', 'PTO'] end |
#normal ⇒ Object
59 60 61 |
# File 'app/models/work_unit/finders.rb', line 59 def normal where(:hours_type => 'Normal') end |
#not_invoiced ⇒ Object
15 16 17 |
# File 'app/models/work_unit/finders.rb', line 15 def not_invoiced where(:invoiced => [nil, '']) end |
#on_estimated_ticket ⇒ Object
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 |
#overtime ⇒ Object
55 56 57 |
# File 'app/models/work_unit/finders.rb', line 55 def overtime where(:hours_type => 'Overtime') end |
#pto ⇒ Object
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_at ⇒ Object
43 44 45 |
# File 'app/models/work_unit/finders.rb', line 43 def sort_by_scheduled_at order('scheduled_at DESC') end |
#unpaid ⇒ Object
11 12 13 |
# File 'app/models/work_unit/finders.rb', line 11 def unpaid where(:paid => [nil, '']) end |