##// END OF EJS Templates
Fixed: Issue Summary tables that list by user are not sorted (#4552)....
Jean-Philippe Lang -
r3209:f8b52b13a08b
parent child
Show More
@@ -1,200 +1,200
1 1 # redMine - project management software
2 2 # Copyright (C) 2006 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 class ReportsController < ApplicationController
19 19 menu_item :issues
20 20 before_filter :find_project, :authorize
21 21
22 22 def issue_report
23 23 @statuses = IssueStatus.find(:all, :order => 'position')
24 24
25 25 case params[:detail]
26 26 when "tracker"
27 27 @field = "tracker_id"
28 28 @rows = @project.trackers
29 29 @data = issues_by_tracker
30 30 @report_title = l(:field_tracker)
31 31 render :template => "reports/issue_report_details"
32 32 when "version"
33 33 @field = "fixed_version_id"
34 34 @rows = @project.shared_versions.sort
35 35 @data = issues_by_version
36 36 @report_title = l(:field_version)
37 37 render :template => "reports/issue_report_details"
38 38 when "priority"
39 39 @field = "priority_id"
40 40 @rows = IssuePriority.all
41 41 @data = issues_by_priority
42 42 @report_title = l(:field_priority)
43 43 render :template => "reports/issue_report_details"
44 44 when "category"
45 45 @field = "category_id"
46 46 @rows = @project.issue_categories
47 47 @data = issues_by_category
48 48 @report_title = l(:field_category)
49 49 render :template => "reports/issue_report_details"
50 50 when "assigned_to"
51 51 @field = "assigned_to_id"
52 @rows = @project.members.collect { |m| m.user }
52 @rows = @project.members.collect { |m| m.user }.sort
53 53 @data = issues_by_assigned_to
54 54 @report_title = l(:field_assigned_to)
55 55 render :template => "reports/issue_report_details"
56 56 when "author"
57 57 @field = "author_id"
58 @rows = @project.members.collect { |m| m.user }
58 @rows = @project.members.collect { |m| m.user }.sort
59 59 @data = issues_by_author
60 60 @report_title = l(:field_author)
61 61 render :template => "reports/issue_report_details"
62 62 when "subproject"
63 63 @field = "project_id"
64 64 @rows = @project.descendants.active
65 65 @data = issues_by_subproject
66 66 @report_title = l(:field_subproject)
67 67 render :template => "reports/issue_report_details"
68 68 else
69 69 @trackers = @project.trackers
70 70 @versions = @project.shared_versions.sort
71 71 @priorities = IssuePriority.all
72 72 @categories = @project.issue_categories
73 @assignees = @project.members.collect { |m| m.user }
74 @authors = @project.members.collect { |m| m.user }
73 @assignees = @project.members.collect { |m| m.user }.sort
74 @authors = @project.members.collect { |m| m.user }.sort
75 75 @subprojects = @project.descendants.active
76 76 issues_by_tracker
77 77 issues_by_version
78 78 issues_by_priority
79 79 issues_by_category
80 80 issues_by_assigned_to
81 81 issues_by_author
82 82 issues_by_subproject
83 83
84 84 render :template => "reports/issue_report"
85 85 end
86 86 end
87 87
88 88 private
89 89 # Find project of id params[:id]
90 90 def find_project
91 91 @project = Project.find(params[:id])
92 92 rescue ActiveRecord::RecordNotFound
93 93 render_404
94 94 end
95 95
96 96 def issues_by_tracker
97 97 @issues_by_tracker ||=
98 98 ActiveRecord::Base.connection.select_all("select s.id as status_id,
99 99 s.is_closed as closed,
100 100 t.id as tracker_id,
101 101 count(i.id) as total
102 102 from
103 103 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{Tracker.table_name} t
104 104 where
105 105 i.status_id=s.id
106 106 and i.tracker_id=t.id
107 107 and i.project_id=#{@project.id}
108 108 group by s.id, s.is_closed, t.id")
109 109 end
110 110
111 111 def issues_by_version
112 112 @issues_by_version ||=
113 113 ActiveRecord::Base.connection.select_all("select s.id as status_id,
114 114 s.is_closed as closed,
115 115 v.id as fixed_version_id,
116 116 count(i.id) as total
117 117 from
118 118 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{Version.table_name} v
119 119 where
120 120 i.status_id=s.id
121 121 and i.fixed_version_id=v.id
122 122 and i.project_id=#{@project.id}
123 123 group by s.id, s.is_closed, v.id")
124 124 end
125 125
126 126 def issues_by_priority
127 127 @issues_by_priority ||=
128 128 ActiveRecord::Base.connection.select_all("select s.id as status_id,
129 129 s.is_closed as closed,
130 130 p.id as priority_id,
131 131 count(i.id) as total
132 132 from
133 133 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{IssuePriority.table_name} p
134 134 where
135 135 i.status_id=s.id
136 136 and i.priority_id=p.id
137 137 and i.project_id=#{@project.id}
138 138 group by s.id, s.is_closed, p.id")
139 139 end
140 140
141 141 def issues_by_category
142 142 @issues_by_category ||=
143 143 ActiveRecord::Base.connection.select_all("select s.id as status_id,
144 144 s.is_closed as closed,
145 145 c.id as category_id,
146 146 count(i.id) as total
147 147 from
148 148 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{IssueCategory.table_name} c
149 149 where
150 150 i.status_id=s.id
151 151 and i.category_id=c.id
152 152 and i.project_id=#{@project.id}
153 153 group by s.id, s.is_closed, c.id")
154 154 end
155 155
156 156 def issues_by_assigned_to
157 157 @issues_by_assigned_to ||=
158 158 ActiveRecord::Base.connection.select_all("select s.id as status_id,
159 159 s.is_closed as closed,
160 160 a.id as assigned_to_id,
161 161 count(i.id) as total
162 162 from
163 163 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a
164 164 where
165 165 i.status_id=s.id
166 166 and i.assigned_to_id=a.id
167 167 and i.project_id=#{@project.id}
168 168 group by s.id, s.is_closed, a.id")
169 169 end
170 170
171 171 def issues_by_author
172 172 @issues_by_author ||=
173 173 ActiveRecord::Base.connection.select_all("select s.id as status_id,
174 174 s.is_closed as closed,
175 175 a.id as author_id,
176 176 count(i.id) as total
177 177 from
178 178 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a
179 179 where
180 180 i.status_id=s.id
181 181 and i.author_id=a.id
182 182 and i.project_id=#{@project.id}
183 183 group by s.id, s.is_closed, a.id")
184 184 end
185 185
186 186 def issues_by_subproject
187 187 @issues_by_subproject ||=
188 188 ActiveRecord::Base.connection.select_all("select s.id as status_id,
189 189 s.is_closed as closed,
190 190 i.project_id as project_id,
191 191 count(i.id) as total
192 192 from
193 193 #{Issue.table_name} i, #{IssueStatus.table_name} s
194 194 where
195 195 i.status_id=s.id
196 196 and i.project_id IN (#{@project.descendants.active.collect{|p| p.id}.join(',')})
197 197 group by s.id, s.is_closed, i.project_id") if @project.descendants.active.any?
198 198 @issues_by_subproject ||= []
199 199 end
200 200 end
General Comments 0
You need to be logged in to leave comments. Login now