diff options
Diffstat (limited to 'app/finders/packages/helm/packages_finder.rb')
-rw-r--r-- | app/finders/packages/helm/packages_finder.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/app/finders/packages/helm/packages_finder.rb b/app/finders/packages/helm/packages_finder.rb new file mode 100644 index 00000000000..c58d9292e9f --- /dev/null +++ b/app/finders/packages/helm/packages_finder.rb @@ -0,0 +1,30 @@ +# frozen_string_literal: true + +module Packages + module Helm + class PackagesFinder + include ::Packages::FinderHelper + + MAX_PACKAGES_COUNT = 300 + + 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 |