Welcome to mirror list, hosted at ThFree Co, Russian Federation.

packages_finder.rb « helm « packages « finders « app - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: e1b831ca8644b4ef17abd97aa3948e99f9593806 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

module Packages
  module Helm
    class PackagesFinder
      include ::Packages::FinderHelper

      MAX_PACKAGES_COUNT = 1000

      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