summaryrefslogtreecommitdiff
path: root/app/finders
diff options
context:
space:
mode:
authorJacob Schatz <jschatz@gitlab.com>2016-08-19 14:57:09 +0000
committerJacob Schatz <jschatz@gitlab.com>2016-08-19 14:57:09 +0000
commit8e14a40769d37595d45ac0faf9167f4dbf7dd054 (patch)
treef4c9bc0d3671681c92daeec38e2ac7b6be662798 /app/finders
parent39820d8013aa550470180ac609ad70c40098d035 (diff)
parentff903e645335901355ab837accc995408f79e96a (diff)
downloadgitlab-ce-8e14a40769d37595d45ac0faf9167f4dbf7dd054.tar.gz
Merge branch '17932-move-to-project-dropdown' into 'master'
Move to project dropdown with infinite scroll for better performance ## What does this MR do? On the Move dropdown on the edit issue page we introduced infinite scrolling to just return a limited number of projects, 50 items. So if the user can move the issue to 50 or more items when scroll down on the list a new set of projects will be requested to the server. ## Are there points in the code the reviewer needs to double check? ## Why was this MR needed? See #17932 ## What are the relevant issue numbers? Closes #17932 ## Screenshots (if relevant) ## Does this MR meet the acceptance criteria? - [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added - ~~[ ] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~ - ~~[ ] API support added~~ - Tests - [x] Added for this feature/bug - [x] All builds are passing - [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides) - [x] Branch has no merge conflicts with `master` (if you do - rebase it please) - [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits) See merge request !5686
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/move_to_project_finder.rb6
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