From 9c7cd890b7da8b35fb0f8e8db362c956e87e4dc4 Mon Sep 17 00:00:00 2001
From: Brad Beattie <bradbeattie@gmail.com>
Date: Thu, 14 May 2009 11:53:37 -0700
Subject: [PATCH] Making the total issues over time graph include sub-projects

---
 app/controllers/graphs_controller.rb | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/app/controllers/graphs_controller.rb b/app/controllers/graphs_controller.rb
index 93451cd..b537a54 100644
--- a/app/controllers/graphs_controller.rb
+++ b/app/controllers/graphs_controller.rb
@@ -103,7 +103,11 @@ class GraphsController < ApplicationController
         sql << " FROM issues"
         sql << " LEFT JOIN #{Project.table_name} ON #{Issue.table_name}.project_id = #{Project.table_name}.id"
         sql << " WHERE (%s)" % Project.allowed_to_condition(User.current, :view_issues)
-        sql << " AND (project_id = #{@project.id})" unless @project.nil? 
+        unless @project.nil?
+            sql << " AND (project_id = #{@project.id}"
+            sql << "    OR project_id IN (%s)" % @project.descendants.active.visible.collect { |p| p.id }.join(',') unless @project.descendants.active.visible.nil?
+            sql << " )"
+        end 
         sql << " GROUP BY project_id"
         sql << " ORDER BY issue_count DESC"
         sql << " LIMIT 6"