@@ -123,17 +123,20 class Version < ActiveRecord::Base | |||||
123 |
|
123 | |||
124 | # Returns assigned issues count |
|
124 | # Returns assigned issues count | |
125 | def issues_count |
|
125 | def issues_count | |
126 | @issue_count ||= fixed_issues.count |
|
126 | load_issue_counts | |
|
127 | @issue_count | |||
127 | end |
|
128 | end | |
128 |
|
129 | |||
129 | # Returns the total amount of open issues for this version. |
|
130 | # Returns the total amount of open issues for this version. | |
130 | def open_issues_count |
|
131 | def open_issues_count | |
131 | @open_issues_count ||= Issue.open.count(:all, :conditions => ["fixed_version_id = ?", self.id]) |
|
132 | load_issue_counts | |
|
133 | @open_issues_count | |||
132 | end |
|
134 | end | |
133 |
|
135 | |||
134 | # Returns the total amount of closed issues for this version. |
|
136 | # Returns the total amount of closed issues for this version. | |
135 | def closed_issues_count |
|
137 | def closed_issues_count | |
136 | @closed_issues_count ||= Issue.open(false).count(:all, :conditions => ["fixed_version_id = ?", self.id]) |
|
138 | load_issue_counts | |
|
139 | @closed_issues_count | |||
137 | end |
|
140 | end | |
138 |
|
141 | |||
139 | def wiki_page |
|
142 | def wiki_page | |
@@ -194,6 +197,21 class Version < ActiveRecord::Base | |||||
194 |
|
197 | |||
195 | private |
|
198 | private | |
196 |
|
199 | |||
|
200 | def load_issue_counts | |||
|
201 | unless @issue_count | |||
|
202 | @open_issues_count = 0 | |||
|
203 | @closed_issues_count = 0 | |||
|
204 | fixed_issues.count(:all, :group => :status).each do |status, count| | |||
|
205 | if status.is_closed? | |||
|
206 | @closed_issues_count += count | |||
|
207 | else | |||
|
208 | @open_issues_count += count | |||
|
209 | end | |||
|
210 | end | |||
|
211 | @issue_count = @open_issues_count + @closed_issues_count | |||
|
212 | end | |||
|
213 | end | |||
|
214 | ||||
197 | # Update the issue's fixed versions. Used if a version's sharing changes. |
|
215 | # Update the issue's fixed versions. Used if a version's sharing changes. | |
198 | def update_issues_from_sharing_change |
|
216 | def update_issues_from_sharing_change | |
199 | if sharing_changed? |
|
217 | if sharing_changed? |
General Comments 0
You need to be logged in to leave comments.
Login now