From 0653e08efd039a5905f3fa4f6e9cef9f5d2f799c Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Mon, 20 Sep 2021 13:18:24 +0000 Subject: Add latest changes from gitlab-org/gitlab@14-3-stable-ee --- app/finders/packages/helm/package_files_finder.rb | 2 ++ app/finders/packages/helm/packages_finder.rb | 30 +++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 app/finders/packages/helm/packages_finder.rb (limited to 'app/finders/packages/helm') 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 -- cgit v1.2.1