Class: Backlog
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Backlog
- Defined in:
- app/models/backlog.rb
Instance Method Summary collapse
- #active_tasks ⇒ Object
- #enable_invoicing? ⇒ Boolean
- #estimate_data(date) ⇒ Object
- #first_active_period ⇒ Object
- #recent_tasks ⇒ Object
- #work_data(date) ⇒ Object
Instance Method Details
#active_tasks ⇒ Object
14 15 16 |
# File 'app/models/backlog.rb', line 14 def active_tasks tasks.find(:all, :conditions => "finished_at IS NULL", :order => "position") end |
#enable_invoicing? ⇒ Boolean
45 46 47 |
# File 'app/models/backlog.rb', line 45 def enable_invoicing? !invoice_code.nil? && invoice_code.length > 0 end |
#estimate_data(date) ⇒ Object
22 23 24 25 26 27 28 |
# File 'app/models/backlog.rb', line 22 def estimate_data(date) total = 0 periods.each do |period| total += period.estimate_data(date) end total end |
#first_active_period ⇒ Object
38 39 40 41 42 43 |
# File 'app/models/backlog.rb', line 38 def first_active_period t = active_tasks periods = t.map {|t| t.period}.compact.uniq periods = periods.select {|p| p.active?} periods.sort_by {|p| p.end_on}.first end |
#recent_tasks ⇒ Object
18 19 20 |
# File 'app/models/backlog.rb', line 18 def recent_tasks Task.find(:all, :conditions => "period_id = #{periods.first.id} AND (position IS NOT NULL OR finished_at >= '#{1.week.ago.iso8601}')", :order => "position, finished_at") end |
#work_data(date) ⇒ Object
30 31 32 33 34 35 36 |
# File 'app/models/backlog.rb', line 30 def work_data(date) total = 0 periods.each do |period| total += period.work_data(date) end total end |