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