##// END OF EJS Templates
Added details by assignees on issue summary view (Hans Yoon)....
Jean-Philippe Lang -
r1038:a39f655a7c86
parent child
Show More
@@ -1,213 +1,236
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 layout 'base'
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::get_values('IPRI')
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 when "assigned_to"
51 @field = "assigned_to_id"
52 @rows = @project.members.collect { |m| m.user }
53 @data = issues_by_assigned_to
54 @report_title = l(:field_assigned_to)
55 render :template => "reports/issue_report_details"
50 56 when "author"
51 57 @field = "author_id"
52 58 @rows = @project.members.collect { |m| m.user }
53 59 @data = issues_by_author
54 60 @report_title = l(:field_author)
55 61 render :template => "reports/issue_report_details"
56 62 when "subproject"
57 63 @field = "project_id"
58 64 @rows = @project.active_children
59 65 @data = issues_by_subproject
60 66 @report_title = l(:field_subproject)
61 67 render :template => "reports/issue_report_details"
62 68 else
63 69 @trackers = @project.trackers
64 70 @versions = @project.versions.sort
65 71 @priorities = Enumeration::get_values('IPRI')
66 72 @categories = @project.issue_categories
73 @assignees = @project.members.collect { |m| m.user }
67 74 @authors = @project.members.collect { |m| m.user }
68 75 @subprojects = @project.active_children
69 76 issues_by_tracker
70 77 issues_by_version
71 78 issues_by_priority
72 79 issues_by_category
80 issues_by_assigned_to
73 81 issues_by_author
74 82 issues_by_subproject
75 83
76 84 render :template => "reports/issue_report"
77 85 end
78 86 end
79 87
80 88 def delays
81 89 @trackers = Tracker.find(:all)
82 90 if request.get?
83 91 @selected_tracker_ids = @trackers.collect {|t| t.id.to_s }
84 92 else
85 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
86 94 end
87 95 @selected_tracker_ids ||= []
88 96 @raw =
89 97 ActiveRecord::Base.connection.select_all("SELECT datediff( a.created_on, b.created_on ) as delay, count(a.id) as total
90 98 FROM issue_histories a, issue_histories b, issues i
91 99 WHERE a.status_id =5
92 100 AND a.issue_id = b.issue_id
93 101 AND a.issue_id = i.id
94 102 AND i.tracker_id in (#{@selected_tracker_ids.join(',')})
95 103 AND b.id = (
96 104 SELECT min( c.id )
97 105 FROM issue_histories c
98 106 WHERE b.issue_id = c.issue_id )
99 107 GROUP BY delay") unless @selected_tracker_ids.empty?
100 108 @raw ||=[]
101 109
102 110 @x_from = 0
103 111 @x_to = 0
104 112 @y_from = 0
105 113 @y_to = 0
106 114 @sum_total = 0
107 115 @sum_delay = 0
108 116 @raw.each do |r|
109 117 @x_to = [r['delay'].to_i, @x_to].max
110 118 @y_to = [r['total'].to_i, @y_to].max
111 119 @sum_total = @sum_total + r['total'].to_i
112 120 @sum_delay = @sum_delay + r['total'].to_i * r['delay'].to_i
113 121 end
114 122 end
115 123
116 124 private
117 125 # Find project of id params[:id]
118 126 def find_project
119 127 @project = Project.find(params[:id])
120 128 rescue ActiveRecord::RecordNotFound
121 129 render_404
122 130 end
123 131
124 132 def issues_by_tracker
125 133 @issues_by_tracker ||=
126 134 ActiveRecord::Base.connection.select_all("select s.id as status_id,
127 135 s.is_closed as closed,
128 136 t.id as tracker_id,
129 137 count(i.id) as total
130 138 from
131 139 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{Tracker.table_name} t
132 140 where
133 141 i.status_id=s.id
134 142 and i.tracker_id=t.id
135 143 and i.project_id=#{@project.id}
136 144 group by s.id, s.is_closed, t.id")
137 145 end
138 146
139 147 def issues_by_version
140 148 @issues_by_version ||=
141 149 ActiveRecord::Base.connection.select_all("select s.id as status_id,
142 150 s.is_closed as closed,
143 151 v.id as fixed_version_id,
144 152 count(i.id) as total
145 153 from
146 154 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{Version.table_name} v
147 155 where
148 156 i.status_id=s.id
149 157 and i.fixed_version_id=v.id
150 158 and i.project_id=#{@project.id}
151 159 group by s.id, s.is_closed, v.id")
152 160 end
153 161
154 162 def issues_by_priority
155 163 @issues_by_priority ||=
156 164 ActiveRecord::Base.connection.select_all("select s.id as status_id,
157 165 s.is_closed as closed,
158 166 p.id as priority_id,
159 167 count(i.id) as total
160 168 from
161 169 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{Enumeration.table_name} p
162 170 where
163 171 i.status_id=s.id
164 172 and i.priority_id=p.id
165 173 and i.project_id=#{@project.id}
166 174 group by s.id, s.is_closed, p.id")
167 175 end
168 176
169 177 def issues_by_category
170 178 @issues_by_category ||=
171 179 ActiveRecord::Base.connection.select_all("select s.id as status_id,
172 180 s.is_closed as closed,
173 181 c.id as category_id,
174 182 count(i.id) as total
175 183 from
176 184 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{IssueCategory.table_name} c
177 185 where
178 186 i.status_id=s.id
179 187 and i.category_id=c.id
180 188 and i.project_id=#{@project.id}
181 189 group by s.id, s.is_closed, c.id")
182 190 end
183
191
192 def issues_by_assigned_to
193 @issues_by_assigned_to ||=
194 ActiveRecord::Base.connection.select_all("select s.id as status_id,
195 s.is_closed as closed,
196 a.id as assigned_to_id,
197 count(i.id) as total
198 from
199 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a
200 where
201 i.status_id=s.id
202 and i.assigned_to_id=a.id
203 and i.project_id=#{@project.id}
204 group by s.id, s.is_closed, a.id")
205 end
206
184 207 def issues_by_author
185 208 @issues_by_author ||=
186 209 ActiveRecord::Base.connection.select_all("select s.id as status_id,
187 210 s.is_closed as closed,
188 211 a.id as author_id,
189 212 count(i.id) as total
190 213 from
191 214 #{Issue.table_name} i, #{IssueStatus.table_name} s, #{User.table_name} a
192 215 where
193 216 i.status_id=s.id
194 217 and i.author_id=a.id
195 218 and i.project_id=#{@project.id}
196 219 group by s.id, s.is_closed, a.id")
197 220 end
198 221
199 222 def issues_by_subproject
200 223 @issues_by_subproject ||=
201 224 ActiveRecord::Base.connection.select_all("select s.id as status_id,
202 225 s.is_closed as closed,
203 226 i.project_id as project_id,
204 227 count(i.id) as total
205 228 from
206 229 #{Issue.table_name} i, #{IssueStatus.table_name} s
207 230 where
208 231 i.status_id=s.id
209 232 and i.project_id IN (#{@project.active_children.collect{|p| p.id}.join(',')})
210 233 group by s.id, s.is_closed, i.project_id") if @project.active_children.any?
211 234 @issues_by_subproject ||= []
212 235 end
213 236 end
@@ -1,28 +1,31
1 1 <h2><%=l(:label_report_plural)%></h2>
2 2
3 3 <div class="splitcontentleft">
4 4 <h3><%=l(:field_tracker)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :detail => 'tracker' %></h3>
5 5 <%= render :partial => 'simple', :locals => { :data => @issues_by_tracker, :field_name => "tracker_id", :rows => @trackers } %>
6 6 <br />
7 <h3><%=l(:field_version)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :detail => 'version' %></h3>
8 <%= render :partial => 'simple', :locals => { :data => @issues_by_version, :field_name => "fixed_version_id", :rows => @versions } %>
7 <h3><%=l(:field_priority)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :detail => 'priority' %></h3>
8 <%= render :partial => 'simple', :locals => { :data => @issues_by_priority, :field_name => "priority_id", :rows => @priorities } %>
9 <br />
10 <h3><%=l(:field_assigned_to)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :detail => 'assigned_to' %></h3>
11 <%= render :partial => 'simple', :locals => { :data => @issues_by_assigned_to, :field_name => "assigned_to_id", :rows => @assignees } %>
9 12 <br />
10 13 <h3><%=l(:field_author)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :detail => 'author' %></h3>
11 14 <%= render :partial => 'simple', :locals => { :data => @issues_by_author, :field_name => "author_id", :rows => @authors } %>
12 15 <br />
13 16 </div>
14 17
15 18 <div class="splitcontentright">
16 <h3><%=l(:field_priority)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :detail => 'priority' %></h3>
17 <%= render :partial => 'simple', :locals => { :data => @issues_by_priority, :field_name => "priority_id", :rows => @priorities } %>
19 <h3><%=l(:field_version)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :detail => 'version' %></h3>
20 <%= render :partial => 'simple', :locals => { :data => @issues_by_version, :field_name => "fixed_version_id", :rows => @versions } %>
18 21 <br />
19 22 <% if @project.children.any? %>
20 23 <h3><%=l(:field_subproject)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :detail => 'subproject' %></h3>
21 24 <%= render :partial => 'simple', :locals => { :data => @issues_by_subproject, :field_name => "project_id", :rows => @subprojects } %>
22 25 <br />
23 26 <% end %>
24 27 <h3><%=l(:field_category)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :detail => 'category' %></h3>
25 28 <%= render :partial => 'simple', :locals => { :data => @issues_by_category, :field_name => "category_id", :rows => @categories } %>
26 29 <br />
27 30 </div>
28 31
General Comments 0
You need to be logged in to leave comments. Login now