blob: d91ef853a1a853974e4963b45dc0772aef7365ad (
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
51
52
|
# frozen_string_literal: true
module Packages
module Nuget
class PackageFinder
include ::Packages::FinderHelper
MAX_PACKAGES_COUNT = 300
def initialize(current_user, project_or_group, package_name:, package_version: nil, limit: MAX_PACKAGES_COUNT)
@current_user = current_user
@project_or_group = project_or_group
@package_name = package_name
@package_version = package_version
@limit = limit
end
def execute
packages.limit_recent(@limit)
end
private
def base
if project?
packages_for_project(@project_or_group)
elsif group?
packages_visible_to_user(@current_user, within_group: @project_or_group)
else
::Packages::Package.none
end
end
def packages
result = base.nuget
.has_version
.processed
.with_name_like(@package_name)
result = result.with_version(@package_version) if @package_version.present?
result
end
def project?
@project_or_group.is_a?(::Project)
end
def group?
@project_or_group.is_a?(::Group)
end
end
end
end
|