debian-mirror-gitlab/app/finders/move_to_project_finder.rb

22 lines
609 B
Ruby
Raw Normal View History

2016-09-13 17:45:13 +05:30
class MoveToProjectFinder
2016-09-29 09:46:39 +05:30
PAGE_SIZE = 50
2016-09-13 17:45:13 +05:30
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)
2018-03-17 18:26:18 +05:30
projects = projects.order_id_desc
2016-09-13 17:45:13 +05:30
2016-09-29 09:46:39 +05:30
# infinite scroll using offset
projects = projects.where('projects.id < ?', offset_id) if offset_id.present?
projects = projects.limit(PAGE_SIZE)
2016-09-13 17:45:13 +05:30
# to ask for Project#name_with_namespace
projects.includes(namespace: :owner)
end
end