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