summaryrefslogtreecommitdiff
path: root/app/controllers/users_controller.rb
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-05 20:37:35 +0300
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-06-05 20:37:35 +0300
commit0fdce4a52b1a9ba9e0efd98f00e558e4f07daeb5 (patch)
tree9305a29f92c3d6763d6b7038ac65a71ec67e087e /app/controllers/users_controller.rb
parent4ca6ebf017e93686ee885ee1a28dc5c6934c9d39 (diff)
downloadgitlab-ce-0fdce4a52b1a9ba9e0efd98f00e558e4f07daeb5.tar.gz
Refactor some search scopes to prevent wierd behaviour and PG::Error issues
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/controllers/users_controller.rb')
-rw-r--r--app/controllers/users_controller.rb17
1 files changed, 13 insertions, 4 deletions
diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb
index c17c6f9694a..0b442f5383a 100644
--- a/app/controllers/users_controller.rb
+++ b/app/controllers/users_controller.rb
@@ -4,15 +4,24 @@ class UsersController < ApplicationController
def show
@user = User.find_by_username!(params[:username])
- @projects = Project.personal(@user).accessible_to(current_user)
unless current_user || @user.public_profile?
return authenticate_user!
end
- @groups = @user.groups.accessible_to(current_user)
- accessible_projects = @user.authorized_projects.accessible_to(current_user)
- @events = @user.recent_events.where(project_id: accessible_projects.pluck(:id)).limit(20)
+ # Projects user can view
+ authorized_projects_ids = ProjectsFinder.new.execute(current_user).pluck(:id)
+
+ @projects = @user.personal_projects.
+ where(id: authorized_projects_ids)
+
+ # Collect only groups common for both users
+ @groups = @user.groups & GroupsFinder.new.execute(current_user)
+
+ # Get user activity feed for projects common for both users
+ @events = @user.recent_events.
+ where(project_id: authorized_projects_ids).limit(20)
+
@title = @user.name
end