Class: Packages::Helm::PackagesFinder

Inherits:
Object
  • Object
show all
Includes:
FinderHelper
Defined in:
app/finders/packages/helm/packages_finder.rb

Constant Summary collapse

MAX_PACKAGES_COUNT =
1000

Constants included from FinderHelper

FinderHelper::InvalidPackageTypeError, FinderHelper::InvalidStatusError

Instance Method Summary collapse

Constructor Details

#initialize(project, channel) ⇒ PackagesFinder

Returns a new instance of PackagesFinder.



10
11
12
13
# File 'app/finders/packages/helm/packages_finder.rb', line 10

def initialize(project, channel)
  @project = project
  @channel = channel
end

Instance Method Details

#executeObject



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'app/finders/packages/helm/packages_finder.rb', line 15

def execute
  if @channel.blank? || @project.blank?
    return ::Packages::Package.none
  end

  pkg_files = ::Packages::PackageFile.for_helm_with_channel(@project, @channel)

  # we use a subquery to get unique packages and at the same time
  # order + limit them.
  ::Packages::Package
    .limit_recent(MAX_PACKAGES_COUNT)
    .id_in(pkg_files.select(:package_id))
end