@issues = @query.issues(:order => sort_clause,
:offset => @offset,
:limit => @limit)
- @issue_count_by_group = @query.issue_count_by_group
respond_to do |format|
format.html { render :template => 'issues/index', :layout => !request.xhr? }
end
end
- def grouped_issue_list(issues, query, issue_count_by_group, &block)
+ def grouped_issue_list(issues, query, &block)
ancestors = []
- grouped_query_results(issues, query, issue_count_by_group) do |issue, group_name, group_count, group_totals|
+ grouped_query_results(issues, query) do |issue, group_name, group_count, group_totals|
while (ancestors.any? && !issue.is_descendant_of?(ancestors.last))
ancestors.pop
end
render :partial => 'queries/columns', :locals => {:query => query, :tag_name => tag_name}
end
- def grouped_query_results(items, query, item_count_by_group, &block)
+ def grouped_query_results(items, query, &block)
+ result_count_by_group = query.result_count_by_group
previous_group, first = false, true
totals_by_group = query.totalable_columns.inject({}) do |h, column|
h[column] = query.total_by_group_for(column)
group_name = format_object(group)
end
group_name ||= ""
- group_count = item_count_by_group ? item_count_by_group[group] : nil
+ group_count = result_count_by_group ? result_count_by_group[group] : nil
group_totals = totals_by_group.map {|column, t| total_tag(column, t[group] || 0)}.join(" ").html_safe
end
end
raise StatementInvalid.new(e.message)
end
- # Returns the issue count by group or nil if query is not grouped
- def issue_count_by_group
- grouped_query do |scope|
- scope.count
- end
- end
-
# Returns sum of all the issue's estimated_hours
def total_for_estimated_hours(scope)
map_total(scope.sum(:estimated_hours)) {|t| t.to_f.round(2)}
filters_clauses.any? ? filters_clauses.join(' AND ') : nil
end
+ # Returns the result count by group or nil if query is not grouped
+ def result_count_by_group
+ grouped_query do |scope|
+ scope.count
+ end
+ end
+
# Returns the sum of values for the given column
def total_for(column)
total_with_scope(column, base_scope)
</tr>
</thead>
<tbody>
- <% grouped_issue_list(issues, query, issue_count_by_group) do |issue, level, group_name, group_count, group_totals| -%>
+ <% grouped_issue_list(issues, query) do |issue, level, group_name, group_count, group_totals| -%>
<% if group_name %>
<% reset_cycle %>
<tr class="group open">
<p class="nodata"><%= l(:label_no_data) %></p>
<% else %>
<%= render_query_totals(@query) %>
-<%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query, :issue_count_by_group => @issue_count_by_group} %>
+<%= render :partial => 'issues/list', :locals => {:issues => @issues, :query => @query} %>
<span class="pagination"><%= pagination_links_full @issue_pages, @issue_count %></span>
<% end %>
</tr>
</thead>
<tbody>
-<% grouped_query_results(entries, @query, @entry_count_by_group) do |entry, group_name, group_count, group_totals| -%>
+<% grouped_query_results(entries, @query) do |entry, group_name, group_count, group_totals| -%>
<% if group_name %>
<% reset_cycle %>
<tr class="group open">
totals_by_group = query.totals_by_group
render_table_header(pdf, query, col_width, row_height, table_width)
previous_group = false
+ result_count_by_group = query.result_count_by_group
+
issue_list(issues) do |issue, level|
if query.grouped? &&
(group = query.group_by_column.value(issue)) != previous_group
pdf.SetFontStyle('B',10)
group_label = group.blank? ? 'None' : group.to_s.dup
- group_label << " (#{query.issue_count_by_group[group]})"
+ group_label << " (#{result_count_by_group[group]})"
pdf.bookmark group_label, 0, -1
pdf.RDMCell(table_width, row_height * 2, group_label, 'LR', 1, 'L')
pdf.SetFontStyle('',8)
def test_issue_count_by_association_group
q = IssueQuery.new(:name => '_', :group_by => 'assigned_to')
- count_by_group = q.issue_count_by_group
+ count_by_group = q.result_count_by_group
assert_kind_of Hash, count_by_group
assert_equal %w(NilClass User), count_by_group.keys.collect {|k| k.class.name}.uniq.sort
assert_equal %W(#{INTEGER_KLASS}), count_by_group.values.collect {|k| k.class.name}.uniq
def test_issue_count_by_list_custom_field_group
q = IssueQuery.new(:name => '_', :group_by => 'cf_1')
- count_by_group = q.issue_count_by_group
+ count_by_group = q.result_count_by_group
assert_kind_of Hash, count_by_group
assert_equal %w(NilClass String), count_by_group.keys.collect {|k| k.class.name}.uniq.sort
assert_equal %W(#{INTEGER_KLASS}), count_by_group.values.collect {|k| k.class.name}.uniq
def test_issue_count_by_date_custom_field_group
q = IssueQuery.new(:name => '_', :group_by => 'cf_8')
- count_by_group = q.issue_count_by_group
+ count_by_group = q.result_count_by_group
assert_kind_of Hash, count_by_group
assert_equal %w(Date NilClass), count_by_group.keys.collect {|k| k.class.name}.uniq.sort
assert_equal %W(#{INTEGER_KLASS}), count_by_group.values.collect {|k| k.class.name}.uniq
Issue.update_all("assigned_to_id = NULL")
q = IssueQuery.new(:name => '_', :group_by => 'assigned_to')
- count_by_group = q.issue_count_by_group
+ count_by_group = q.result_count_by_group
assert_kind_of Hash, count_by_group
assert_equal 1, count_by_group.keys.size
assert_nil count_by_group.keys.first