Class: Version

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

Overview

redMine - project management software Copyright (C) 2006 Jean-Philippe Lang

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Instance Method Summary (collapse)

Instance Method Details

- (Object) <=>(version)

Versions are sorted by effective_date and name Those with no effective_date are at the end, sorted by name



100
101
102
103
104
105
106
# File 'app/models/version.rb', line 100

def <=>(version)
  if self.effective_date
    version.effective_date ? (self.effective_date == version.effective_date ? self.name <=> version.name : self.effective_date <=> version.effective_date) : -1
  else
    version.effective_date ? 1 : (self.name <=> version.name)
  end
end

- (Object) closed_issues_count



85
86
87
# File 'app/models/version.rb', line 85

def closed_issues_count
  @closed_issues_count ||= Issue.count(:all, :conditions => ["fixed_version_id = ? AND is_closed = ?", self.id, true], :include => :status)
end

- (Object) closed_pourcent



63
64
65
66
67
68
69
# File 'app/models/version.rb', line 63

def closed_pourcent
  if issues_count == 0
    0
  else
    issues_progress(false)
  end
end

- (Boolean) completed?

Returns true if the version is completed: due date reached and no open issues



49
50
51
# File 'app/models/version.rb', line 49

def completed?
  effective_date && (effective_date <= Date.today) && (open_issues_count == 0)
end

- (Object) completed_pourcent



53
54
55
56
57
58
59
60
61
# File 'app/models/version.rb', line 53

def completed_pourcent
  if issues_count == 0
    0
  elsif open_issues_count == 0
    100
  else
    issues_progress(false) + issues_progress(true)
  end
end

- (Object) due_date



34
35
36
# File 'app/models/version.rb', line 34

def due_date
  effective_date
end

- (Object) estimated_hours

Returns the total estimated time for this version



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

def estimated_hours
  @estimated_hours ||= fixed_issues.sum(:estimated_hours).to_f
end

- (Object) issues_count

Returns assigned issues count



77
78
79
# File 'app/models/version.rb', line 77

def issues_count
  @issue_count ||= fixed_issues.count
end

- (Object) open_issues_count



81
82
83
# File 'app/models/version.rb', line 81

def open_issues_count
  @open_issues_count ||= Issue.count(:all, :conditions => ["fixed_version_id = ? AND is_closed = ?", self.id, false], :include => :status)
end

- (Boolean) overdue?

Returns true if the version is overdue: due date reached and some open issues



72
73
74
# File 'app/models/version.rb', line 72

def overdue?
  effective_date && (effective_date < Date.today) && (open_issues_count > 0)
end

- (Object) spent_hours

Returns the total reported time for this version



44
45
46
# File 'app/models/version.rb', line 44

def spent_hours
  @spent_hours ||= TimeEntry.sum(:hours, :include => :issue, :conditions => ["#{Issue.table_name}.fixed_version_id = ?", id]).to_f
end

- (Object) start_date



30
31
32
# File 'app/models/version.rb', line 30

def start_date
  effective_date
end

- (Object) to_s



96
# File 'app/models/version.rb', line 96

def to_s; name end

- (Object) wiki_page



89
90
91
92
93
94
# File 'app/models/version.rb', line 89

def wiki_page
  if project.wiki && !wiki_page_title.blank?
    @wiki_page ||= project.wiki.find_page(wiki_page_title)
  end
  @wiki_page
end