summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2017-03-09 20:01:01 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2017-03-09 20:01:01 +0000
commitb714c714024796d3cd3bd215b07b4d8798a35406 (patch)
treecf80ecad1125c44db2b8510ce93f819aeaf394da /app
parent364d1aa72746424b87e1a17823612096db7c3ae3 (diff)
downloadredmine-b714c714024796d3cd3bd215b07b4d8798a35406.tar.gz
redmine-b714c714024796d3cd3bd215b07b4d8798a35406.zip
Get the count by group from the query directly.
git-svn-id: http://svn.redmine.org/redmine/trunk@16387 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app')
-rw-r--r--app/controllers/issues_controller.rb1
-rw-r--r--app/helpers/issues_helper.rb4
-rw-r--r--app/helpers/queries_helper.rb5
-rw-r--r--app/models/issue_query.rb7
-rw-r--r--app/models/query.rb7
-rw-r--r--app/views/issues/_list.html.erb2
-rw-r--r--app/views/issues/index.html.erb2
-rw-r--r--app/views/timelog/_list.html.erb2
8 files changed, 15 insertions, 15 deletions
diff --git a/app/controllers/issues_controller.rb b/app/controllers/issues_controller.rb
index 906130e1a..a04c1a6b0 100644
--- a/app/controllers/issues_controller.rb
+++ b/app/controllers/issues_controller.rb
@@ -69,7 +69,6 @@ class IssuesController < ApplicationController
@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? }
diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb
index f95338284..703607999 100644
--- a/app/helpers/issues_helper.rb
+++ b/app/helpers/issues_helper.rb
@@ -32,9 +32,9 @@ module IssuesHelper
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
diff --git a/app/helpers/queries_helper.rb b/app/helpers/queries_helper.rb
index c356ca0d4..197bbb998 100644
--- a/app/helpers/queries_helper.rb
+++ b/app/helpers/queries_helper.rb
@@ -115,7 +115,8 @@ module QueriesHelper
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)
@@ -132,7 +133,7 @@ module QueriesHelper
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
diff --git a/app/models/issue_query.rb b/app/models/issue_query.rb
index 7f399f469..71fe8d288 100644
--- a/app/models/issue_query.rb
+++ b/app/models/issue_query.rb
@@ -245,13 +245,6 @@ class IssueQuery < Query
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)}
diff --git a/app/models/query.rb b/app/models/query.rb
index 321821a93..7a43ca6fc 100644
--- a/app/models/query.rb
+++ b/app/models/query.rb
@@ -846,6 +846,13 @@ class Query < ActiveRecord::Base
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)
diff --git a/app/views/issues/_list.html.erb b/app/views/issues/_list.html.erb
index ed97d046f..1e7d01ef7 100644
--- a/app/views/issues/_list.html.erb
+++ b/app/views/issues/_list.html.erb
@@ -14,7 +14,7 @@
</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">
diff --git a/app/views/issues/index.html.erb b/app/views/issues/index.html.erb
index 7828075cf..80210814e 100644
--- a/app/views/issues/index.html.erb
+++ b/app/views/issues/index.html.erb
@@ -16,7 +16,7 @@
<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 %>
diff --git a/app/views/timelog/_list.html.erb b/app/views/timelog/_list.html.erb
index b39eb5cc3..d4836056a 100644
--- a/app/views/timelog/_list.html.erb
+++ b/app/views/timelog/_list.html.erb
@@ -15,7 +15,7 @@
</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">