blob: 161a3d0d409f8cc282342b3fb52e2c0ce77a41a7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# frozen_string_literal: true
module Packages
module Conan
class PackageFinder
MAX_PACKAGES_COUNT = 500
def initialize(current_user, params, project: nil)
@current_user = current_user
@query = params[:query]
@project = project
end
def execute
return ::Packages::Package.none unless query
packages
end
private
attr_reader :current_user, :query, :project
def packages
base
.conan
.installable
.preload_conan_metadatum
.with_name_like(query)
.limit_recent(MAX_PACKAGES_COUNT)
end
def base
project ? packages_of_project : packages_for_current_user
end
def packages_of_project
project.packages
end
def packages_for_current_user
Packages::Package.for_projects(projects_visible_to_current_user)
end
def projects_visible_to_current_user
::Project.public_or_visible_to_user(current_user, ::Gitlab::Access::REPORTER)
end
end
end
end
|