Perhaps this could help:
I updated the versions_helper.rb
file, the render_issue_status_by
method this way:
def render_issue_status_by(version, criteria)
criteria ||= 'category'
raise 'Unknown criteria' unless STATUS_BY_CRITERIAS.include?(criteria)
h = Hash.new {|k,v| k[v] = [0, 0]}
if criteria == 'assigned_to'
begin
# Total estimated hours
Issue.sum("estimated_hours",
:group => criteria,
:conditions => ["#{Issue.table_name}.estimated_hours is not NULL AND #{Issue.table_name}.fixed_version_id = ?", version.id]).each {|c,s| h[c][0] = s.to_i}
# Open issues count
Issue.sum("(estimated_hours * (100 - done_ratio)) / 100",
:group => criteria,
:include => :status,
:conditions => ["#{Issue.table_name}.estimated_hours is not NULL AND #{Issue.table_name}.fixed_version_id = ? AND #{IssueStatus.table_name}.is_closed = ?", version.id, false]).each {|c,s| h[c][1] = s.to_i}
rescue ActiveRecord::RecordNotFound
# When grouping by an association, Rails throws this exception if there's no result (bug)
end
else
begin
# Total issue count
Issue.count(:group => criteria,
:conditions => ["#{Issue.table_name}.fixed_version_id = ?", version.id]).each {|c,s| h[c][0] = s}
# Open issues count
Issue.count(:group => criteria,
:include => :status,
:conditions => ["#{Issue.table_name}.fixed_version_id = ? AND #{IssueStatus.table_name}.is_closed = ?", version.id, false]).each {|c,s| h[c][1] = s}
rescue ActiveRecord::RecordNotFound
# When grouping by an association, Rails throws this exception if there's no result (bug)
end
end
counts = h.keys.compact.sort.collect {|k| {:group => k, :total => h[k][0], :open => h[k][1], :closed => (h[k][0] - h[k][1])}}
max = counts.collect {|c| c[:total]}.max
render :partial => 'issue_counts', :locals => {:version => version, :criteria => criteria, :counts => counts, :max => max}
end
It appears to do what I needed: It displays the estimated hours rather than the issues counts.
Could you please include my piece of code with one of the next Redmine releases, as another option pickable from the dropdown?
Thank you & best regards,
Jiri.