Class: Packages::Helm::PackagesFinder

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

Constant Summary

Constants included from FinderHelper

FinderHelper::InvalidPackageTypeError, FinderHelper::InvalidStatusError

Instance Method Summary collapse

Constructor Details

#initialize(project, channel, with_recent_limit: true) ⇒ PackagesFinder

Returns a new instance of PackagesFinder.



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

def initialize(project, channel, with_recent_limit: true)
  @project = project
  @channel = channel
  @with_recent_limit = with_recent_limit
end

Instance Method Details

#executeObject



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

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

  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.
  query = ::Packages::Package.id_in(pkg_files.select(:package_id))

  query = query.limit_recent(max_packages_count) if @with_recent_limit

  query
end