]> source.dussan.org Git - redmine.git/commitdiff
Issue Summary: add statistics about issues without assignee, version or category...
authorGo MAEDA <maeda@farend.jp>
Sun, 12 Dec 2021 04:40:32 +0000 (04:40 +0000)
committerGo MAEDA <maeda@farend.jp>
Sun, 12 Dec 2021 04:40:32 +0000 (04:40 +0000)
Patch by Takenori TAKAKI.

git-svn-id: http://svn.redmine.org/redmine/trunk@21309 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/reports_controller.rb
app/helpers/reports_helper.rb
app/models/issue.rb
test/functional/reports_controller_test.rb
test/helpers/reports_helper_test.rb [new file with mode: 0644]

index bc9605b6de8fa8994265c11ef30a7418a6e43967..6f6d4c313518d78174caadf9abcdcb98481897a0 100644 (file)
@@ -24,10 +24,10 @@ class ReportsController < ApplicationController
   def issue_report
     with_subprojects = Setting.display_subprojects_issues?
     @trackers = @project.rolled_up_trackers(with_subprojects).visible
-    @versions = @project.shared_versions.sorted
+    @versions = @project.shared_versions.sorted + [Version.new(:name => "[#{l(:label_none)}]")]
     @priorities = IssuePriority.all.reverse
-    @categories = @project.issue_categories
-    @assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted
+    @categories = @project.issue_categories + [IssueCategory.new(:name => "[#{l(:label_none)}]")]
+    @assignees = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted + [User.new(:firstname => "[#{l(:label_none)}]")]
     @authors = @project.users.sorted
     @subprojects = @project.descendants.visible
     @issues_by_tracker = Issue.by_tracker(@project, with_subprojects)
@@ -51,7 +51,7 @@ class ReportsController < ApplicationController
       @report_title = l(:field_tracker)
     when "version"
       @field = "fixed_version_id"
-      @rows = @project.shared_versions.sorted
+      @rows = @project.shared_versions.sorted + [Version.new(:name => "[#{l(:label_none)}]")]
       @data = Issue.by_version(@project, with_subprojects)
       @report_title = l(:field_version)
     when "priority"
@@ -61,12 +61,12 @@ class ReportsController < ApplicationController
       @report_title = l(:field_priority)
     when "category"
       @field = "category_id"
-      @rows = @project.issue_categories
+      @rows = @project.issue_categories + [IssueCategory.new(:name => "[#{l(:label_none)}]")]
       @data = Issue.by_category(@project, with_subprojects)
       @report_title = l(:field_category)
     when "assigned_to"
       @field = "assigned_to_id"
-      @rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted
+      @rows = (Setting.issue_group_assignment? ? @project.principals : @project.users).sorted + [User.new(:firstname => "[#{l(:label_none)}]")]
       @data = Issue.by_assigned_to(@project, with_subprojects)
       @report_title = l(:field_assigned_to)
     when "author"
index 8f8e8eb84f57378bcef82502822b64eb35dbb168..c64ccc768fcffb310bc986338557312b5179ee31 100644 (file)
@@ -41,7 +41,7 @@ module ReportsHelper
   end
 
   def aggregate_path(project, field, row, options={})
-    parameters = {:set_filter => 1, :subproject_id => '!*', field => row.id}.merge(options)
+    parameters = {:set_filter => 1, :subproject_id => '!*', field => (row.id || '!*')}.merge(options)
     project_issues_path(row.is_a?(Project) ? row : project, parameters)
   end
 end
index 5c1911eb8dc66069ae77e7ef33f3d3818a3084a9..b51e186cb3781ace0464121b279b8e81c306f7fd 100644 (file)
@@ -1585,7 +1585,7 @@ class Issue < ActiveRecord::Base
 
     Issue.
       visible(User.current, :project => options[:project], :with_subprojects => options[:with_subprojects]).
-      joins(:status, assoc.name).
+      joins(:status).
       group(:status_id, :is_closed, select_field).
       count.
       map do |columns, total|
index f2b3e69f019554b4ab5e2d7233cdcc7ee86fd8a4..ca7ad67998aaf67d190552e961d2906653928a98 100644 (file)
@@ -208,6 +208,30 @@ class ReportsControllerTest < Redmine::ControllerTest
     end
   end
 
+  def test_get_issue_report_details_by_assignee_should_show_non_assigned_issue_count
+    Issue.delete_all
+    Issue.generate!
+    Issue.generate!
+    Issue.generate!(:status_id => 5)
+    Issue.generate!(:assigned_to_id => 2)
+
+    get(
+      :issue_report_details,
+      :params => {
+        :id => 1,
+        :detail => 'assigned_to'
+      }
+    )
+    assert_select 'table.list tbody :last-child' do
+      assert_select 'td', :text => "[#{I18n.t(:label_none)}]"
+      assert_select ':nth-child(2)', :text => '2' # status:1
+      assert_select ':nth-child(6)', :text => '1' # status:5
+      assert_select ':nth-child(8)', :text => '2' # open
+      assert_select ':nth-child(9)', :text => '1' # closed
+      assert_select ':nth-child(10)', :text => '3' # total
+    end
+  end
+
   def test_get_issue_report_details_with_an_invalid_detail
     get(
       :issue_report_details,
diff --git a/test/helpers/reports_helper_test.rb b/test/helpers/reports_helper_test.rb
new file mode 100644 (file)
index 0000000..09ed6de
--- /dev/null
@@ -0,0 +1,41 @@
+# frozen_string_literal: true
+
+# Redmine - project management software
+# Copyright (C) 2006-2021  Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+
+require File.expand_path('../../test_helper', __FILE__)
+
+class ReportsHlperTest < Redmine::HelperTest
+  include ReportsHelper
+  include Rails.application.routes.url_helpers
+
+  fixtures :projects, :users
+
+  def test_aggregate_path_for_spacified_row
+    project = Project.find(1)
+    field = 'assigned_to_id'
+    row = User.find(2)
+    assert_equal '/projects/ecookbook/issues?assigned_to_id=2&set_filter=1&subproject_id=%21%2A', aggregate_path(project, field, row)
+  end
+
+  def test_aggregate_path_for_unset_row
+    project = Project.find(1)
+    field = 'assigned_to_id'
+    row = User.new
+    assert_equal '/projects/ecookbook/issues?assigned_to_id=%21%2A&set_filter=1&subproject_id=%21%2A', aggregate_path(project, field, row)
+  end
+end