Commit 3e28dc66 authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

various eager loadings added

git-svn-id: http://redmine.rubyforge.org/svn/trunk@98 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent bee3f353
......@@ -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
......
......@@ -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
}
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment