Merge pull request #1998 from erroric/gitlabhq_issue1669

fix for issue #1669
This commit is contained in:
Dmitriy Zaporozhets 2012-11-20 14:10:45 -08:00
commit dc9916b474
3 changed files with 4 additions and 4 deletions

View file

@ -5,7 +5,7 @@ class DashboardController < ApplicationController
def index def index
@groups = Group.where(id: current_user.projects.pluck(:group_id)) @groups = Group.where(id: current_user.projects.pluck(:group_id))
@projects = current_user.projects_with_events @projects = current_user.projects_sorted_by_activity
@projects = @projects.page(params[:page]).per(30) @projects = @projects.page(params[:page]).per(30)
@events = Event.in_projects(current_user.project_ids) @events = Event.in_projects(current_user.project_ids)

View file

@ -54,7 +54,7 @@ class GroupsController < ApplicationController
end end
def projects def projects
@projects ||= current_user.projects_with_events.where(group_id: @group.id) @projects ||= current_user.projects_sorted_by_activity.where(group_id: @group.id)
end end
def project_ids def project_ids

View file

@ -67,7 +67,7 @@ module Account
events = events.recent.limit(1).first events = events.recent.limit(1).first
end end
def projects_with_events def projects_sorted_by_activity
projects.includes(:events).order("events.created_at DESC") projects.order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC")
end end
end end