Class: Backlog

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/backlog.rb

Instance Method Summary collapse

Instance Method Details

#active_tasksObject



16
17
18
# File 'app/models/backlog.rb', line 16

def active_tasks
  tasks.find(:all, :conditions => "finished_at IS NULL", :order => "position")
end

#enable_invoicing?Boolean

Returns:

  • (Boolean)


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

def enable_invoicing?
  !invoice_code.nil? && invoice_code.length > 0
end

#estimate_data(date) ⇒ Object



24
25
26
27
28
29
30
# File 'app/models/backlog.rb', line 24

def estimate_data(date)
  total = 0
  periods.each do |period|
    total += period.estimate_data(date)
  end
  total
end

#first_active_periodObject



40
41
42
43
44
45
# File 'app/models/backlog.rb', line 40

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_tasksObject



20
21
22
# File 'app/models/backlog.rb', line 20

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



32
33
34
35
36
37
38
# File 'app/models/backlog.rb', line 32

def work_data(date)
  total = 0
  periods.each do |period|
    total += period.work_data(date)
  end
  total
end