Commit dc9916b4 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #1998 from erroric/gitlabhq_issue1669

fix for issue #1669
parents 68b119f6 31bf0cd8
......@@ -5,7 +5,7 @@ class DashboardController < ApplicationController
def index
@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)
@events = Event.in_projects(current_user.project_ids)
......
......@@ -54,7 +54,7 @@ class GroupsController < ApplicationController
end
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
def project_ids
......
......@@ -67,7 +67,7 @@ module Account
events = events.recent.limit(1).first
end
def projects_with_events
projects.includes(:events).order("events.created_at DESC")
def projects_sorted_by_activity
projects.order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC")
end
end
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