Added subprojects issue count on project "Reports" page

git-svn-id: http://redmine.rubyforge.org/svn/trunk@410 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2007-04-03 19:48:49 +00:00
parent 1c0971b12c
commit 52ced19e2e
4 changed files with 37 additions and 9 deletions

View File

@ -47,16 +47,24 @@ class ReportsController < ApplicationController
@data = issues_by_author @data = issues_by_author
@report_title = l(:field_author) @report_title = l(:field_author)
render :template => "reports/issue_report_details" render :template => "reports/issue_report_details"
when "subproject"
@field = "project_id"
@rows = @project.children
@data = issues_by_subproject
@report_title = l(:field_subproject)
render :template => "reports/issue_report_details"
else else
@queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)] @queries = @project.queries.find :all, :conditions => ["is_public=? or user_id=?", true, (logged_in_user ? logged_in_user.id : 0)]
@trackers = Tracker.find(:all, :order => 'position') @trackers = Tracker.find(:all, :order => 'position')
@priorities = Enumeration::get_values('IPRI') @priorities = Enumeration::get_values('IPRI')
@categories = @project.issue_categories @categories = @project.issue_categories
@authors = @project.members.collect { |m| m.user } @authors = @project.members.collect { |m| m.user }
@subprojects = @project.children
issues_by_tracker issues_by_tracker
issues_by_priority issues_by_priority
issues_by_category issues_by_category
issues_by_author issues_by_author
issues_by_subproject
@total_hours = @project.time_entries.sum(:hours) @total_hours = @project.time_entries.sum(:hours)
render :template => "reports/issue_report" render :template => "reports/issue_report"
end end
@ -165,4 +173,19 @@ private
and i.project_id=#{@project.id} and i.project_id=#{@project.id}
group by s.id, s.is_closed, a.id") group by s.id, s.is_closed, a.id")
end end
def issues_by_subproject
@issues_by_subproject ||=
ActiveRecord::Base.connection.select_all("select s.id as status_id,
s.is_closed as closed,
i.project_id as project_id,
count(i.id) as total
from
#{Issue.table_name} i, #{IssueStatus.table_name} s
where
i.status_id=s.id
and i.project_id IN (#{@project.children.collect{|p| p.id}.join(',')})
group by s.id, s.is_closed, i.project_id") if @project.children.any?
@issues_by_subproject ||= []
end
end end

View File

@ -15,28 +15,28 @@
<tbody> <tbody>
<% for row in rows %> <% for row in rows %>
<tr class="<%= cycle("odd", "even") %>"> <tr class="<%= cycle("odd", "even") %>">
<td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project, <td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1, :set_filter => 1,
"#{field_name}" => row.id %></td> "#{field_name}" => row.id %></td>
<% for status in @statuses %> <% for status in @statuses %>
<td align="center"><%= link_to (aggregate data, { field_name => row.id, "status_id" => status.id }), <td align="center"><%= link_to (aggregate data, { field_name => row.id, "status_id" => status.id }),
:controller => 'projects', :action => 'list_issues', :id => @project, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1, :set_filter => 1,
"status_id" => status.id, "status_id" => status.id,
"#{field_name}" => row.id %></td> "#{field_name}" => row.id %></td>
<% end %> <% end %>
<td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 0 }), <td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 0 }),
:controller => 'projects', :action => 'list_issues', :id => @project, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1, :set_filter => 1,
"#{field_name}" => row.id, "#{field_name}" => row.id,
"status_id" => "o" %></td> "status_id" => "o" %></td>
<td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 1 }), <td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 1 }),
:controller => 'projects', :action => 'list_issues', :id => @project, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1, :set_filter => 1,
"#{field_name}" => row.id, "#{field_name}" => row.id,
"status_id" => "c" %></td> "status_id" => "c" %></td>
<td align="center"><%= link_to (aggregate data, { field_name => row.id }), <td align="center"><%= link_to (aggregate data, { field_name => row.id }),
:controller => 'projects', :action => 'list_issues', :id => @project, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1, :set_filter => 1,
"#{field_name}" => row.id, "#{field_name}" => row.id,
"status_id" => "*" %></td> "status_id" => "*" %></td>

View File

@ -11,21 +11,21 @@
<tbody> <tbody>
<% for row in rows %> <% for row in rows %>
<tr class="<%= cycle("odd", "even") %>"> <tr class="<%= cycle("odd", "even") %>">
<td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project, <td><%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1, :set_filter => 1,
"#{field_name}" => row.id %></td> "#{field_name}" => row.id %></td>
<td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 0 }), <td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 0 }),
:controller => 'projects', :action => 'list_issues', :id => @project, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1, :set_filter => 1,
"#{field_name}" => row.id, "#{field_name}" => row.id,
"status_id" => "o" %></td> "status_id" => "o" %></td>
<td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 1 }), <td align="center"><%= link_to (aggregate data, { field_name => row.id, "closed" => 1 }),
:controller => 'projects', :action => 'list_issues', :id => @project, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1, :set_filter => 1,
"#{field_name}" => row.id, "#{field_name}" => row.id,
"status_id" => "c" %></td> "status_id" => "c" %></td>
<td align="center"><%= link_to (aggregate data, { field_name => row.id }), <td align="center"><%= link_to (aggregate data, { field_name => row.id }),
:controller => 'projects', :action => 'list_issues', :id => @project, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)),
:set_filter => 1, :set_filter => 1,
"#{field_name}" => row.id, "#{field_name}" => row.id,
"status_id" => "*" %></td> "status_id" => "*" %></td>

View File

@ -36,6 +36,11 @@
<h3><%=l(:field_priority)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :detail => 'priority' %></h3> <h3><%=l(:field_priority)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :detail => 'priority' %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_priority, :field_name => "priority_id", :rows => @priorities } %> <%= render :partial => 'simple', :locals => { :data => @issues_by_priority, :field_name => "priority_id", :rows => @priorities } %>
<br /> <br />
<% if @project.children.any? %>
<h3><%=l(:field_subproject)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :detail => 'subproject' %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_subproject, :field_name => "project_id", :rows => @subprojects } %>
<br />
<% end %>
<h3><%=l(:field_category)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :detail => 'category' %></h3> <h3><%=l(:field_category)%>&nbsp;&nbsp;<%= link_to image_tag('zoom_in.png'), :detail => 'category' %></h3>
<%= render :partial => 'simple', :locals => { :data => @issues_by_category, :field_name => "category_id", :rows => @categories } %> <%= render :partial => 'simple', :locals => { :data => @issues_by_category, :field_name => "category_id", :rows => @categories } %>
<br /> <br />