diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-08-05 16:29:20 +0300 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-08-17 08:33:51 +0300 |
commit | 03386633a42bd56b0b0b31b70eebaaaa33e1494e (patch) | |
tree | 24913e88546ebfce79f66a84a28e0a2f536776c0 /app/controllers | |
parent | 1b338d59f641ce629cbecb839b64c9fd65561276 (diff) |
Move to project dropdown with infinite scroll for better performance
Use just SQL to check is a user can admin_issue on a project
Tradeoff
- we duplicate how we check admin_issue in a SQL relation in the Ability class
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/autocomplete_controller.rb | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/app/controllers/autocomplete_controller.rb b/app/controllers/autocomplete_controller.rb index e1641ba6265..b48668eea87 100644 --- a/app/controllers/autocomplete_controller.rb +++ b/app/controllers/autocomplete_controller.rb @@ -35,19 +35,13 @@ class AutocompleteController < ApplicationController def projects project = Project.find_by_id(params[:project_id]) - - projects = current_user.authorized_projects - projects = projects.search(params[:search]) if params[:search].present? - projects = projects.select do |project| - current_user.can?(:admin_issue, project) - end + projects = projects_finder.execute(project, search: params[:search], offset_id: params[:offset_id]) no_project = { id: 0, name_with_namespace: 'No project', } - projects.unshift(no_project) - projects.delete(project) + projects.unshift(no_project) unless params[:offset_id].present? render json: projects.to_json(only: [:id, :name_with_namespace], methods: :name_with_namespace) end @@ -79,4 +73,8 @@ class AutocompleteController < ApplicationController end end end + + def projects_finder + MoveToProjectFinder.new(current_user) + end end |