diff options
author | Paco Guzman <pacoguzmanp@gmail.com> | 2016-08-05 15:29:20 +0200 |
---|---|---|
committer | Paco Guzman <pacoguzmanp@gmail.com> | 2016-08-18 15:31:51 +0200 |
commit | ff903e645335901355ab837accc995408f79e96a (patch) | |
tree | 6b2e268690a54339bb11dc2ab2d9c973951c604a /app/finders | |
parent | ac73de508e21af95b473bfafc2ca2543b234430d (diff) | |
download | gitlab-ce-ff903e645335901355ab837accc995408f79e96a.tar.gz |
Move to project dropdown with infinite scroll for better performance17932-move-to-project-dropdown
Use just SQL to check is a user can admin_issue on a project
Using offset pagination instead pages to avoid a count query
Tradeoff
- we duplicate how we check admin_issue in a SQL relation in the Ability class
Diffstat (limited to 'app/finders')
-rw-r--r-- | app/finders/move_to_project_finder.rb | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/app/finders/move_to_project_finder.rb b/app/finders/move_to_project_finder.rb index 3334b8556df..79eb45568be 100644 --- a/app/finders/move_to_project_finder.rb +++ b/app/finders/move_to_project_finder.rb @@ -1,4 +1,6 @@ class MoveToProjectFinder + PAGE_SIZE = 50 + def initialize(user) @user = user end @@ -8,6 +10,10 @@ class MoveToProjectFinder projects = projects.search(search) if search.present? projects = projects.excluding_project(from_project) + # infinite scroll using offset + projects = projects.where('projects.id < ?', offset_id) if offset_id.present? + projects = projects.limit(PAGE_SIZE) + # to ask for Project#name_with_namespace projects.includes(namespace: :owner) end |