Class: MergeRequestTargetProjectFinder

Inherits:
Object
  • Object
show all
Includes:
FinderMethods
Defined in:
app/finders/merge_request_target_project_finder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from FinderMethods

#find, #find_by, #find_by!

Constructor Details

#initialize(source_project:, current_user: nil, project_feature: :merge_requests) ⇒ MergeRequestTargetProjectFinder

Returns a new instance of MergeRequestTargetProjectFinder.



8
9
10
11
12
# File 'app/finders/merge_request_target_project_finder.rb', line 8

def initialize(source_project:, current_user: nil, project_feature: :merge_requests)
  @current_user = current_user
  @source_project = source_project
  @project_feature = project_feature
end

Instance Attribute Details

#current_userObject (readonly)

Returns the value of attribute current_user.



6
7
8
# File 'app/finders/merge_request_target_project_finder.rb', line 6

def current_user
  @current_user
end

#source_projectObject (readonly)

Returns the value of attribute source_project.



6
7
8
# File 'app/finders/merge_request_target_project_finder.rb', line 6

def source_project
  @source_project
end

Instance Method Details

#execute(search: nil, include_routes: false) ⇒ Object



14
15
16
17
18
19
20
21
22
# File 'app/finders/merge_request_target_project_finder.rb', line 14

def execute(search: nil, include_routes: false)
  if source_project.fork_network
    items = include_routes ? projects.inc_routes : projects
    by_search(items, search).allow_cross_joins_across_databases(
      url: "https://gitlab.com/gitlab-org/gitlab/-/issues/420046")
  else
    Project.id_in(source_project.id)
  end
end