Project

General

Profile

Patch #4776 » sumEstimatedTimeByGroup.patch

Ewan Makepeace, 2010-02-09 08:25

View differences:

controllers/issues_controller.rb (working copy)
:offset => @issue_pages.current.offset,
:limit => limit)
@issue_count_by_group = @query.issue_count_by_group
@issue_sum_by_group = @query.issue_sum_by_group
respond_to do |format|
format.html { render :template => 'issues/index.rhtml', :layout => !request.xhr? }
models/query.rb (working copy)
raise StatementInvalid.new(e.message)
end
# Returns sum of all the issue's estimated_hours
def issue_sum
Issue.sum(:estimated_hours, :include => [:status, :project], :conditions => statement)
rescue ::ActiveRecord::StatementInvalid => e
raise StatementInvalid.new(e.message)
end
# Returns the issue count by group or nil if query is not grouped
def issue_count_by_group
r = nil
......
raise StatementInvalid.new(e.message)
end
# Returns sum of the issue's estimated_hours by group or nil if query is not grouped
def issue_sum_by_group
r = nil
if grouped?
begin
r = Issue.sum(:estimated_hours, :group => group_by_statement, :include => [:status, :project], :conditions => statement)
rescue ActiveRecord::RecordNotFound
r= {r => issue_sum}
end
c = group_by_column
if c.is_a?(QueryCustomFieldColumn)
r = r.keys.inject({}) {|h, k| h[c.custom_field.cast_value(k)] = r[k]; h}
end
end
r
rescue ::ActiveRecord::StatementInvalid => e
raise StatementInvalid.new(e.message)
end
# Returns the issues
# Valid options are :order, :offset, :limit, :include, :conditions
def issues(options={})
views/issues/_list.rhtml (working copy)
<tr class="group open">
<td colspan="<%= query.columns.size + 2 %>">
<span class="expander" onclick="toggleRowGroup(this); return false;">&nbsp;</span>
<%= group.blank? ? 'None' : column_content(@query.group_by_column, issue) %> <span class="count">(<%= @issue_count_by_group[group] %>)</span>
<%= group.blank? ? 'None' : column_content(@query.group_by_column, issue) %> <span class="count">(<%= @issue_count_by_group[group] %>, <%= l(:label_total) %>:<%= @issue_sum_by_group[group] %>)</span>
</td>
</tr>
<% previous_group = group %>
(4-4/13)