debian-mirror-gitlab/app/finders/packages/helm/packages_finder.rb

31 lines
719 B
Ruby
Raw Normal View History

2021-11-11 11:23:49 +05:30
# frozen_string_literal: true
module Packages
module Helm
class PackagesFinder
include ::Packages::FinderHelper
2022-11-25 23:54:43 +05:30
MAX_PACKAGES_COUNT = 1000
2021-11-11 11:23:49 +05:30
def initialize(project, channel)
@project = project
@channel = channel
end
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
end
end
end