Project

General

Profile

Patch #4776 » TotalEstimatedTime.patch

Ewan Makepeace, 2010-02-09 08:25

View differences:

app/helpers/reports_helper.rb (working copy)
module ReportsHelper
def aggregate(data, criteria)
a = 0
def aggregate_link(data, criteria, *args)
a,b = 0,0
data.each { |row|
match = 1
criteria.each { |k, v|
match = 0 unless (row[k].to_s == v.to_s) || (k == 'closed' && row[k] == (v == 0 ? "f" : "t"))
} unless criteria.nil?
a = a + row["total"].to_i if match == 1
a,b = a + row["total"].to_i, b+row["hours"].to_i if match == 1
} unless data.nil?
a
end
def aggregate_link(data, criteria, *args)
a = aggregate data, criteria
a > 0 ? link_to(a, *args) : '-'
a > 0 ? link_to(a.to_s + " (" + b.to_s + ")", *args) : '-'
end
end
app/controllers/issues_controller.rb (working copy)
# Find potential statuses the user could be allowed to switch issues to
@available_statuses = Workflow.find(:all, :include => :new_status,
:conditions => {:role_id => current_role.id}).collect(&:new_status).compact.uniq.sort
@custom_fields = @project.issue_custom_fields.select {|f| f.field_format == 'list'}
@custom_fields = @project.all_issue_custom_fields.select {|f| f.field_format == 'list'}
end
def move
app/controllers/reports_controller.rb (working copy)
ActiveRecord::Base.connection.select_all("select s.id as status_id,
s.is_closed as closed,
t.id as tracker_id,
count(i.id) as total
count(i.id) as total,
sum(i.estimated_hours) as hours
from
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{Tracker.table_name} t
where
......
ActiveRecord::Base.connection.select_all("select s.id as status_id,
s.is_closed as closed,
v.id as fixed_version_id,
count(i.id) as total
count(i.id) as total,
sum(i.estimated_hours) as hours
from
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{Version.table_name} v
where
......
ActiveRecord::Base.connection.select_all("select s.id as status_id,
s.is_closed as closed,
p.id as priority_id,
count(i.id) as total
count(i.id) as total,
sum(i.estimated_hours) as hours
from
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{Enumeration.table_name} p
where
......
ActiveRecord::Base.connection.select_all("select s.id as status_id,
s.is_closed as closed,
c.id as category_id,
count(i.id) as total
count(i.id) as total,
sum(i.estimated_hours) as hours
from
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{IssueCategory.table_name} c
where
......
ActiveRecord::Base.connection.select_all("select s.id as status_id,
s.is_closed as closed,
a.id as assigned_to_id,
count(i.id) as total
count(i.id) as total,
sum(i.estimated_hours) as hours
from
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a
where
......
ActiveRecord::Base.connection.select_all("select s.id as status_id,
s.is_closed as closed,
a.id as author_id,
count(i.id) as total
count(i.id) as total,
sum(i.estimated_hours) as hours
from
#{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a
where
......
ActiveRecord::Base.connection.select_all("select s.id as status_id,
s.is_closed as closed,
i.project_id as project_id,
count(i.id) as total
count(i.id) as total,
sum(i.estimated_hours) as hours
from
#{Issue.table_name} i, #{IssueStatus.table_name} s
where
app/views/issues/_list.rhtml (working copy)
<% end -%>
</tbody>
</table>
<p align="right">
Current page: <b><%= @issues.collect(&:estimated_hours).reject {|hours| hours.nil?}.sum %></b>
Total: <b><%= @estimated = Issue.sum :estimated_hours,
:include => [ :assigned_to, :status, :tracker, :project, :priority, :category, :fixed_version ],
:conditions => @query.statement %></b>
</p>
<% end -%>
(3-3/13)