Commit ec260430b924fd7f8fcb9499aa8aba70569e0363
- Date: Sat Jan 26 21:43:18 +0000 2008
- Committer: Johan Sørensen (johan@johansorensen.com)
- Author: Johan Sørensen (johan@johansorensen.com)
- Commit SHA1: ec260430b924fd7f8fcb9499aa8aba70569e0363
- Tree SHA1: 8eecc88f7255b8de68fb5217ce271d52abd4f8e5
less 1+N queries on dashboard
Commit diff
| |   |
| 10 | 10 | @projects = current_user.projects |
| 11 | 11 | project_ids = @projects.map(&:id) |
| 12 | 12 | @recent_comments = Comment.find(:all, :limit => 10, |
| 13 | | :conditions => ["project_id in (?)", project_ids], :order => "created_at desc") |
| 13 | :conditions => ["comments.project_id in (?)", project_ids], |
| 14 | :order => "comments.created_at desc", :include => [:user, :repository]) |
| 14 | 15 | @repository_clones = @projects.map(&:repository_clones).flatten |
| 15 | 16 | # @repository_clones = Repository.find(:all, |
| 16 | 17 | # :conditions => ["project_id in (?) and mainline = ?", project_ids, false]) |
| toggle raw diff |
--- a/app/controllers/site_controller.rb
+++ b/app/controllers/site_controller.rb
@@ -10,7 +10,8 @@ class SiteController < ApplicationController
@projects = current_user.projects
project_ids = @projects.map(&:id)
@recent_comments = Comment.find(:all, :limit => 10,
- :conditions => ["project_id in (?)", project_ids], :order => "created_at desc")
+ :conditions => ["comments.project_id in (?)", project_ids],
+ :order => "comments.created_at desc", :include => [:user, :repository])
@repository_clones = @projects.map(&:repository_clones).flatten
# @repository_clones = Repository.find(:all,
# :conditions => ["project_id in (?) and mainline = ?", project_ids, false]) |