OSDN Git Service

various eager loadings added
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 16 Dec 2006 17:33:31 +0000 (17:33 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 16 Dec 2006 17:33:31 +0000 (17:33 +0000)
git-svn-id: http://redmine.rubyforge.org/svn/trunk@98 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/controllers/application.rb
app/controllers/projects_controller.rb
app/models/project.rb

index 45c3206..483d0a1 100644 (file)
@@ -25,7 +25,7 @@ class ApplicationController < ActionController::Base
   \r
   def logged_in_user\r
     if session[:user_id]\r
-      @logged_in_user ||= User.find(session[:user_id], :include => :memberships)\r
+      @logged_in_user ||= User.find(session[:user_id])\r
     else\r
       nil\r
     end\r
index a31b7ec..4151e73 100644 (file)
@@ -175,7 +175,7 @@ class ProjectsController < ApplicationController
   \r
   # Show documents list of @project
   def list_documents\r
-    @documents = @project.documents\r
+    @documents = @project.documents.find :all, :include => :category\r
   end\r
 \r
   # Add a new issue to @project\r
@@ -398,7 +398,7 @@ class ProjectsController < ApplicationController
     end\r
     \r
     unless params[:show_news] == "0"\r
-      @project.news.find(:all, :conditions => ["news.created_on>=? and news.created_on<=?", @date_from, @date_to] ).each { |i|\r
+      @project.news.find(:all, :conditions => ["news.created_on>=? and news.created_on<=?", @date_from, @date_to], :include => :author ).each { |i|\r
         @events_by_day[i.created_on.to_date] ||= []\r
         @events_by_day[i.created_on.to_date] << i\r
       }\r
@@ -406,7 +406,7 @@ class ProjectsController < ApplicationController
     end\r
     \r
     unless params[:show_files] == "0"\r
-      Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN versions ON versions.id = attachments.container_id", :conditions => ["attachments.container_type='Version' and versions.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to] ).each { |i|\r
+      Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN versions ON versions.id = attachments.container_id", :conditions => ["attachments.container_type='Version' and versions.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i|\r
         @events_by_day[i.created_on.to_date] ||= []\r
         @events_by_day[i.created_on.to_date] << i\r
       }\r
@@ -418,7 +418,7 @@ class ProjectsController < ApplicationController
         @events_by_day[i.created_on.to_date] ||= []\r
         @events_by_day[i.created_on.to_date] << i\r
       }\r
-      Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN documents ON documents.id = attachments.container_id", :conditions => ["attachments.container_type='Document' and documents.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to] ).each { |i|\r
+      Attachment.find(:all, :select => "attachments.*", :joins => "LEFT JOIN documents ON documents.id = attachments.container_id", :conditions => ["attachments.container_type='Document' and documents.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to], :include => :author ).each { |i|\r
         @events_by_day[i.created_on.to_date] ||= []\r
         @events_by_day[i.created_on.to_date] << i\r
       }\r
index cf17f0f..83197df 100644 (file)
@@ -20,7 +20,7 @@ class Project < ActiveRecord::Base
   has_many :members, :dependent => true\r
   has_many :users, :through => :members\r
   has_many :custom_values, :dependent => true, :as => :customized\r
-  has_many :issues, :dependent => true, :order => "issues.created_on DESC", :include => :status\r
+  has_many :issues, :dependent => true, :order => "issues.created_on DESC", :include => [:status, :tracker]\r
   has_many :queries, :dependent => true\r
   has_many :documents, :dependent => true\r
   has_many :news, :dependent => true, :include => :author\r