##// END OF EJS Templates
Removes unused code....
Jean-Philippe Lang -
r2476:df6e29f76695
parent child
Show More
@@ -1,236 +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.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 = Enumeration.priorities
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 52 @rows = @project.members.collect { |m| m.user }
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 58 @rows = @project.members.collect { |m| m.user }
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.versions.sort
71 71 @priorities = Enumeration.priorities
72 72 @categories = @project.issue_categories
73 73 @assignees = @project.members.collect { |m| m.user }
74 74 @authors = @project.members.collect { |m| m.user }
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 def delays
89 @trackers = Tracker.find(:all)
90 if request.get?
91 @selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
92 else
93 @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array
94 end
95 @selected_tracker_ids ||= []
96 @raw =
97 ActiveRecord::Base.connection.select_all("SELECT datediff( a.created_on, b.created_on ) as delay, count(a.id) as total
98 FROM issue_histories a, issue_histories b, issues i
99 WHERE a.status_id =5
100 AND a.issue_id = b.issue_id
101 AND a.issue_id = i.id
102 AND i.tracker_id in (#{@selected_tracker_ids.join(',')})
103 AND b.id = (
104 SELECT min( c.id )
105 FROM issue_histories c
106 WHERE b.issue_id = c.issue_id )
107 GROUP BY delay") unless @selected_tracker_ids.empty?
108 @raw ||=[]
109
110 @x_from = 0
111 @x_to = 0
112 @y_from = 0
113 @y_to = 0
114 @sum_total = 0
115 @sum_delay = 0
116 @raw.each do |r|
117 @x_to = [r['delay'].to_i, @x_to].max
118 @y_to = [r['total'].to_i, @y_to].max
119 @sum_total = @sum_total + r['total'].to_i
120 @sum_delay = @sum_delay + r['total'].to_i * r['delay'].to_i
121 end
122 end
123
124 88 private
125 89 # Find project of id params[:id]
126 90 def find_project
127 91 @project = Project.find(params[:id])
128 92 rescue ActiveRecord::RecordNotFound
129 93 render_404
130 94 end
131 95
132 96 def issues_by_tracker
133 97 @issues_by_tracker ||=
134 98 ActiveRecord::Base.connection.select_all("select s.id as status_id,
135 99 s.is_closed as closed,
136 100 t.id as tracker_id,
137 101 count(i.id) as total
138 102 from
139 103 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{Tracker.table_name} t
140 104 where
141 105 i.status_id=s.id
142 106 and i.tracker_id=t.id
143 107 and i.project_id=#{@project.id}
144 108 group by s.id, s.is_closed, t.id")
145 109 end
146 110
147 111 def issues_by_version
148 112 @issues_by_version ||=
149 113 ActiveRecord::Base.connection.select_all("select s.id as status_id,
150 114 s.is_closed as closed,
151 115 v.id as fixed_version_id,
152 116 count(i.id) as total
153 117 from
154 118 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{Version.table_name} v
155 119 where
156 120 i.status_id=s.id
157 121 and i.fixed_version_id=v.id
158 122 and i.project_id=#{@project.id}
159 123 group by s.id, s.is_closed, v.id")
160 124 end
161 125
162 126 def issues_by_priority
163 127 @issues_by_priority ||=
164 128 ActiveRecord::Base.connection.select_all("select s.id as status_id,
165 129 s.is_closed as closed,
166 130 p.id as priority_id,
167 131 count(i.id) as total
168 132 from
169 133 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{Enumeration.table_name} p
170 134 where
171 135 i.status_id=s.id
172 136 and i.priority_id=p.id
173 137 and i.project_id=#{@project.id}
174 138 group by s.id, s.is_closed, p.id")
175 139 end
176 140
177 141 def issues_by_category
178 142 @issues_by_category ||=
179 143 ActiveRecord::Base.connection.select_all("select s.id as status_id,
180 144 s.is_closed as closed,
181 145 c.id as category_id,
182 146 count(i.id) as total
183 147 from
184 148 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{IssueCategory.table_name} c
185 149 where
186 150 i.status_id=s.id
187 151 and i.category_id=c.id
188 152 and i.project_id=#{@project.id}
189 153 group by s.id, s.is_closed, c.id")
190 154 end
191 155
192 156 def issues_by_assigned_to
193 157 @issues_by_assigned_to ||=
194 158 ActiveRecord::Base.connection.select_all("select s.id as status_id,
195 159 s.is_closed as closed,
196 160 a.id as assigned_to_id,
197 161 count(i.id) as total
198 162 from
199 163 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a
200 164 where
201 165 i.status_id=s.id
202 166 and i.assigned_to_id=a.id
203 167 and i.project_id=#{@project.id}
204 168 group by s.id, s.is_closed, a.id")
205 169 end
206 170
207 171 def issues_by_author
208 172 @issues_by_author ||=
209 173 ActiveRecord::Base.connection.select_all("select s.id as status_id,
210 174 s.is_closed as closed,
211 175 a.id as author_id,
212 176 count(i.id) as total
213 177 from
214 178 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a
215 179 where
216 180 i.status_id=s.id
217 181 and i.author_id=a.id
218 182 and i.project_id=#{@project.id}
219 183 group by s.id, s.is_closed, a.id")
220 184 end
221 185
222 186 def issues_by_subproject
223 187 @issues_by_subproject ||=
224 188 ActiveRecord::Base.connection.select_all("select s.id as status_id,
225 189 s.is_closed as closed,
226 190 i.project_id as project_id,
227 191 count(i.id) as total
228 192 from
229 193 #{Issue.table_name} i, #{IssueStatus.table_name} s
230 194 where
231 195 i.status_id=s.id
232 196 and i.project_id IN (#{@project.descendants.active.collect{|p| p.id}.join(',')})
233 197 group by s.id, s.is_closed, i.project_id") if @project.descendants.active.any?
234 198 @issues_by_subproject ||= []
235 199 end
236 200 end
General Comments 0
You need to be logged in to leave comments. Login now