mirror of
https://github.com/TracksApp/tracks.git
synced 2026-02-03 22:41:48 +01:00
Optimize the number of SQL queries fired off on the home page load by eager loading tags.
git-svn-id: http://www.rousette.org.uk/svn/tracks-repos/trunk@431 a4c988fc-2ded-0310-b66e-134b36920a42
This commit is contained in:
parent
6814c29626
commit
3374679bac
1 changed files with 3 additions and 3 deletions
|
|
@ -17,7 +17,7 @@ class TodosController < ApplicationController
|
|||
# If you've set no_completed to zero, the completed items box
|
||||
# isn't shown on the home page
|
||||
max_completed = @user.prefs.show_number_completed
|
||||
@done = @user.completed_todos.find(:all, :limit => max_completed) unless max_completed == 0
|
||||
@done = @user.completed_todos.find(:all, :limit => max_completed, :include => [ :context, :project, :tags ]) unless max_completed == 0
|
||||
|
||||
@contexts_to_show = @contexts.reject {|x| x.hide? }
|
||||
|
||||
|
|
@ -283,10 +283,10 @@ class TodosController < ApplicationController
|
|||
|
||||
def init_todos
|
||||
# Exclude hidden projects from count on home page
|
||||
@todos = @user.todos.find(:all, :conditions => ['todos.state = ? or todos.state = ?', 'active', 'complete'], :include => [ :project, :context ])
|
||||
@todos = @user.todos.find(:all, :conditions => ['todos.state = ? or todos.state = ?', 'active', 'complete'], :include => [ :project, :context, :tags ])
|
||||
|
||||
# Exclude hidden projects from the home page
|
||||
@not_done_todos = @user.todos.find(:all, :conditions => ['todos.state = ?', 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => [ :project, :context ])
|
||||
@not_done_todos = @user.todos.find(:all, :conditions => ['todos.state = ?', 'active'], :order => "todos.due IS NULL, todos.due ASC, todos.created_at ASC", :include => [ :project, :context, :tags ])
|
||||
end
|
||||
|
||||
def determine_down_count
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue