various eager loadings added

git-svn-id: http://redmine.rubyforge.org/svn/trunk@98 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Jean-Philippe Lang 2006-12-16 17:33:31 +00:00
parent bee3f353fc
commit 3e28dc669b
3 changed files with 6 additions and 6 deletions

View File

@ -25,7 +25,7 @@ class ApplicationController < ActionController::Base
def logged_in_user
if session[:user_id]
@logged_in_user ||= User.find(session[:user_id], :include => :memberships)
@logged_in_user ||= User.find(session[:user_id])
else
nil
end

View File

@ -175,7 +175,7 @@ class ProjectsController < ApplicationController
# Show documents list of @project
def list_documents
@documents = @project.documents
@documents = @project.documents.find :all, :include => :category
end
# Add a new issue to @project
@ -398,7 +398,7 @@ class ProjectsController < ApplicationController
end
unless params[:show_news] == "0"
@project.news.find(:all, :conditions => ["news.created_on>=? and news.created_on<=?", @date_from, @date_to] ).each { |i|
@project.news.find(:all, :conditions => ["news.created_on>=? and news.created_on<=?", @date_from, @date_to], :include => :author ).each { |i|
@events_by_day[i.created_on.to_date] ||= []
@events_by_day[i.created_on.to_date] << i
}
@ -406,7 +406,7 @@ class ProjectsController < ApplicationController
end
unless params[:show_files] == "0"
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|
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|
@events_by_day[i.created_on.to_date] ||= []
@events_by_day[i.created_on.to_date] << i
}
@ -418,7 +418,7 @@ class ProjectsController < ApplicationController
@events_by_day[i.created_on.to_date] ||= []
@events_by_day[i.created_on.to_date] << i
}
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|
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|
@events_by_day[i.created_on.to_date] ||= []
@events_by_day[i.created_on.to_date] << i
}

View File

@ -20,7 +20,7 @@ class Project < ActiveRecord::Base
has_many :members, :dependent => true
has_many :users, :through => :members
has_many :custom_values, :dependent => true, :as => :customized
has_many :issues, :dependent => true, :order => "issues.created_on DESC", :include => :status
has_many :issues, :dependent => true, :order => "issues.created_on DESC", :include => [:status, :tracker]
has_many :queries, :dependent => true
has_many :documents, :dependent => true
has_many :news, :dependent => true, :include => :author