Patch #4776 » TotalEstimatedTime.patch
| app/helpers/reports_helper.rb (working copy) | ||
|---|---|---|
| 17 | 17 | |
| 18 | 18 |
module ReportsHelper |
| 19 | 19 |
|
| 20 |
def aggregate(data, criteria)
|
|
| 21 |
a = 0
|
|
| 20 |
def aggregate_link(data, criteria, *args)
|
|
| 21 |
a,b = 0,0
|
|
| 22 | 22 |
data.each { |row|
|
| 23 | 23 |
match = 1 |
| 24 | 24 |
criteria.each { |k, v|
|
| 25 | 25 |
match = 0 unless (row[k].to_s == v.to_s) || (k == 'closed' && row[k] == (v == 0 ? "f" : "t")) |
| 26 | 26 |
} unless criteria.nil? |
| 27 |
a = a + row["total"].to_i if match == 1
|
|
| 27 |
a,b = a + row["total"].to_i, b+row["hours"].to_i if match == 1
|
|
| 28 | 28 |
} unless data.nil? |
| 29 |
a |
|
| 30 |
end |
|
| 31 |
|
|
| 32 |
def aggregate_link(data, criteria, *args) |
|
| 33 |
a = aggregate data, criteria |
|
| 34 |
a > 0 ? link_to(a, *args) : '-' |
|
| 29 |
|
|
| 30 |
a > 0 ? link_to(a.to_s + " (" + b.to_s + ")", *args) : '-'
|
|
| 35 | 31 |
end |
| 36 | 32 |
end |
| app/controllers/issues_controller.rb (working copy) | ||
|---|---|---|
| 266 | 266 |
# Find potential statuses the user could be allowed to switch issues to |
| 267 | 267 |
@available_statuses = Workflow.find(:all, :include => :new_status, |
| 268 | 268 |
:conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq.sort
|
| 269 |
@custom_fields = @project.issue_custom_fields.select {|f| f.field_format == 'list'}
|
|
| 269 |
@custom_fields = @project.all_issue_custom_fields.select {|f| f.field_format == 'list'}
|
|
| 270 | 270 |
end |
| 271 | 271 | |
| 272 | 272 |
def move |
| app/controllers/reports_controller.rb (working copy) | ||
|---|---|---|
| 134 | 134 |
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
| 135 | 135 |
s.is_closed as closed, |
| 136 | 136 |
t.id as tracker_id, |
| 137 |
count(i.id) as total |
|
| 137 |
count(i.id) as total, |
|
| 138 |
sum(i.estimated_hours) as hours |
|
| 138 | 139 |
from |
| 139 | 140 |
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{Tracker.table_name} t
|
| 140 | 141 |
where |
| ... | ... | |
| 149 | 150 |
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
| 150 | 151 |
s.is_closed as closed, |
| 151 | 152 |
v.id as fixed_version_id, |
| 152 |
count(i.id) as total |
|
| 153 |
count(i.id) as total, |
|
| 154 |
sum(i.estimated_hours) as hours |
|
| 153 | 155 |
from |
| 154 | 156 |
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{Version.table_name} v
|
| 155 | 157 |
where |
| ... | ... | |
| 164 | 166 |
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
| 165 | 167 |
s.is_closed as closed, |
| 166 | 168 |
p.id as priority_id, |
| 167 |
count(i.id) as total |
|
| 169 |
count(i.id) as total, |
|
| 170 |
sum(i.estimated_hours) as hours |
|
| 168 | 171 |
from |
| 169 | 172 |
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{Enumeration.table_name} p
|
| 170 | 173 |
where |
| ... | ... | |
| 179 | 182 |
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
| 180 | 183 |
s.is_closed as closed, |
| 181 | 184 |
c.id as category_id, |
| 182 |
count(i.id) as total |
|
| 185 |
count(i.id) as total, |
|
| 186 |
sum(i.estimated_hours) as hours |
|
| 183 | 187 |
from |
| 184 | 188 |
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{IssueCategory.table_name} c
|
| 185 | 189 |
where |
| ... | ... | |
| 194 | 198 |
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
| 195 | 199 |
s.is_closed as closed, |
| 196 | 200 |
a.id as assigned_to_id, |
| 197 |
count(i.id) as total |
|
| 201 |
count(i.id) as total, |
|
| 202 |
sum(i.estimated_hours) as hours |
|
| 198 | 203 |
from |
| 199 | 204 |
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a
|
| 200 | 205 |
where |
| ... | ... | |
| 209 | 214 |
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
| 210 | 215 |
s.is_closed as closed, |
| 211 | 216 |
a.id as author_id, |
| 212 |
count(i.id) as total |
|
| 217 |
count(i.id) as total, |
|
| 218 |
sum(i.estimated_hours) as hours |
|
| 213 | 219 |
from |
| 214 | 220 |
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a
|
| 215 | 221 |
where |
| ... | ... | |
| 224 | 230 |
ActiveRecord::Base.connection.select_all("select s.id as status_id,
|
| 225 | 231 |
s.is_closed as closed, |
| 226 | 232 |
i.project_id as project_id, |
| 227 |
count(i.id) as total |
|
| 233 |
count(i.id) as total, |
|
| 234 |
sum(i.estimated_hours) as hours |
|
| 228 | 235 |
from |
| 229 | 236 |
#{Issue.table_name} i, #{IssueStatus.table_name} s
|
| 230 | 237 |
where |
| app/views/issues/_list.rhtml (working copy) | ||
|---|---|---|
| 19 | 19 |
<% end -%> |
| 20 | 20 |
</tbody> |
| 21 | 21 |
</table> |
| 22 |
<p align="right"> |
|
| 23 |
Current page: <b><%= @issues.collect(&:estimated_hours).reject {|hours| hours.nil?}.sum %></b>
|
|
| 24 |
Total: <b><%= @estimated = Issue.sum :estimated_hours, |
|
| 25 |
:include => [ :assigned_to, :status, :tracker, :project, :priority, :category, :fixed_version ], |
|
| 26 |
:conditions => @query.statement %></b> |
|
| 27 |
</p> |
|
| 22 | 28 |
<% end -%> |