From: Jean-Philippe Lang Date: Tue, 3 Apr 2007 19:48:49 +0000 (+0000) Subject: Added subprojects issue count on project "Reports" page X-Git-Tag: 0.5.0~34 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=52ced19e2e58b420c83c3dda0637439209f85f4f;p=redmine.git Added subprojects issue count on project "Reports" page git-svn-id: http://redmine.rubyforge.org/svn/trunk@410 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index ab648460b..5536e272c 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -47,16 +47,24 @@ class ReportsController < ApplicationController @data = issues_by_author @report_title = l(:field_author) 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 @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') @priorities = Enumeration::get_values('IPRI') @categories = @project.issue_categories @authors = @project.members.collect { |m| m.user } + @subprojects = @project.children issues_by_tracker issues_by_priority issues_by_category issues_by_author + issues_by_subproject @total_hours = @project.time_entries.sum(:hours) render :template => "reports/issue_report" end @@ -165,4 +173,19 @@ private and i.project_id=#{@project.id} group by s.id, s.is_closed, a.id") 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 diff --git a/app/views/reports/_details.rhtml b/app/views/reports/_details.rhtml index 323816a13..6a2888eaa 100644 --- a/app/views/reports/_details.rhtml +++ b/app/views/reports/_details.rhtml @@ -15,28 +15,28 @@ <% for row in rows %> "> - <%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project, + <%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)), :set_filter => 1, "#{field_name}" => row.id %> <% for status in @statuses %> <%= 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, "status_id" => status.id, "#{field_name}" => row.id %> <% end %> <%= 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, "#{field_name}" => row.id, "status_id" => "o" %> <%= 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, "#{field_name}" => row.id, "status_id" => "c" %> <%= 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, "#{field_name}" => row.id, "status_id" => "*" %> diff --git a/app/views/reports/_simple.rhtml b/app/views/reports/_simple.rhtml index 0e580fe72..20ff41fe2 100644 --- a/app/views/reports/_simple.rhtml +++ b/app/views/reports/_simple.rhtml @@ -11,21 +11,21 @@ <% for row in rows %> "> - <%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => @project, + <%= link_to row.name, :controller => 'projects', :action => 'list_issues', :id => ((row.is_a?(Project) ? row : @project)), :set_filter => 1, "#{field_name}" => row.id %> <%= 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, "#{field_name}" => row.id, "status_id" => "o" %> <%= 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, "#{field_name}" => row.id, "status_id" => "c" %> <%= 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, "#{field_name}" => row.id, "status_id" => "*" %> diff --git a/app/views/reports/issue_report.rhtml b/app/views/reports/issue_report.rhtml index 8f832f87e..1ab9dbdbd 100644 --- a/app/views/reports/issue_report.rhtml +++ b/app/views/reports/issue_report.rhtml @@ -36,6 +36,11 @@

<%=l(:field_priority)%>  <%= link_to image_tag('zoom_in.png'), :detail => 'priority' %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_priority, :field_name => "priority_id", :rows => @priorities } %>
+<% if @project.children.any? %> +

<%=l(:field_subproject)%>  <%= link_to image_tag('zoom_in.png'), :detail => 'subproject' %>

+<%= render :partial => 'simple', :locals => { :data => @issues_by_subproject, :field_name => "project_id", :rows => @subprojects } %> +
+<% end %>

<%=l(:field_category)%>  <%= link_to image_tag('zoom_in.png'), :detail => 'category' %>

<%= render :partial => 'simple', :locals => { :data => @issues_by_category, :field_name => "category_id", :rows => @categories } %>