2016-08-05 09:29:20 -04:00
|
|
|
class MoveToProjectFinder
|
2016-08-05 09:29:20 -04:00
|
|
|
PAGE_SIZE = 50
|
|
|
|
|
2016-08-05 09:29:20 -04:00
|
|
|
def initialize(user)
|
|
|
|
@user = user
|
|
|
|
end
|
|
|
|
|
|
|
|
def execute(from_project, search: nil, offset_id: nil)
|
|
|
|
projects = @user.projects_where_can_admin_issues
|
|
|
|
projects = projects.search(search) if search.present?
|
|
|
|
projects = projects.excluding_project(from_project)
|
|
|
|
|
2016-08-05 09:29:20 -04:00
|
|
|
# infinite scroll using offset
|
|
|
|
projects = projects.where('projects.id < ?', offset_id) if offset_id.present?
|
|
|
|
projects = projects.limit(PAGE_SIZE)
|
|
|
|
|
2016-08-05 09:29:20 -04:00
|
|
|
# to ask for Project#name_with_namespace
|
|
|
|
projects.includes(namespace: :owner)
|
|
|
|
end
|
|
|
|
end
|