diff options
Diffstat (limited to 'app/finders/packages/helm')
-rw-r--r-- | app/finders/packages/helm/package_files_finder.rb | 2 | ||||
-rw-r--r-- | app/finders/packages/helm/packages_finder.rb | 30 |
2 files changed, 32 insertions, 0 deletions
diff --git a/app/finders/packages/helm/package_files_finder.rb b/app/finders/packages/helm/package_files_finder.rb index ba400b27554..c6504d09dce 100644 --- a/app/finders/packages/helm/package_files_finder.rb +++ b/app/finders/packages/helm/package_files_finder.rb @@ -6,6 +6,8 @@ module Packages DEFAULT_PACKAGE_FILES_COUNT = 20 MAX_PACKAGE_FILES_COUNT = 1000 + delegate :most_recent!, to: :execute + def initialize(project, channel, params = {}) @project = project @channel = channel 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 |