diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-05-19 18:44:42 +0300 |
commit | 4555e1b21c365ed8303ffb7a3325d773c9b8bf31 (patch) | |
tree | 5423a1c7516cffe36384133ade12572cf709398d /app/models/packages/package_file.rb | |
parent | e570267f2f6b326480d284e0164a6464ba4081bc (diff) |
Add latest changes from gitlab-org/gitlab@13-12-stable-eev13.12.0-rc42
Diffstat (limited to 'app/models/packages/package_file.rb')
-rw-r--r-- | app/models/packages/package_file.rb | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/app/models/packages/package_file.rb b/app/models/packages/package_file.rb index 23a7144e2bb..3d8641ca2fa 100644 --- a/app/models/packages/package_file.rb +++ b/app/models/packages/package_file.rb @@ -5,7 +5,8 @@ class Packages::PackageFile < ApplicationRecord delegate :project, :project_id, to: :package delegate :conan_file_type, to: :conan_file_metadatum - delegate :file_type, :architecture, :fields, to: :debian_file_metadatum, prefix: :debian + delegate :file_type, :component, :architecture, :fields, to: :debian_file_metadatum, prefix: :debian + delegate :channel, :metadata, to: :helm_file_metadatum, prefix: :helm belongs_to :package @@ -13,9 +14,11 @@ class Packages::PackageFile < ApplicationRecord has_many :package_file_build_infos, inverse_of: :package_file, class_name: 'Packages::PackageFileBuildInfo' has_many :pipelines, through: :package_file_build_infos has_one :debian_file_metadatum, inverse_of: :package_file, class_name: 'Packages::Debian::FileMetadatum' + has_one :helm_file_metadatum, inverse_of: :package_file, class_name: 'Packages::Helm::FileMetadatum' accepts_nested_attributes_for :conan_file_metadatum accepts_nested_attributes_for :debian_file_metadatum + accepts_nested_attributes_for :helm_file_metadatum validates :package, presence: true validates :file, presence: true @@ -24,6 +27,7 @@ class Packages::PackageFile < ApplicationRecord validates :file_name, uniqueness: { scope: :package }, if: -> { package&.pypi? } scope :recent, -> { order(id: :desc) } + scope :for_package_ids, ->(ids) { where(package_id: ids) } scope :with_file_name, ->(file_name) { where(file_name: file_name) } scope :with_file_name_like, ->(file_name) { where(arel_table[:file_name].matches(file_name)) } scope :with_files_stored_locally, -> { where(file_store: ::Packages::PackageFileUploader::Store::LOCAL) } @@ -41,7 +45,17 @@ class Packages::PackageFile < ApplicationRecord scope :with_debian_file_type, ->(file_type) do joins(:debian_file_metadatum) - .where(packages_debian_file_metadata: { debian_file_type: ::Packages::Debian::FileMetadatum.debian_file_types[file_type] }) + .where(packages_debian_file_metadata: { file_type: ::Packages::Debian::FileMetadatum.file_types[file_type] }) + end + + scope :with_debian_component_name, ->(component_name) do + joins(:debian_file_metadatum) + .where(packages_debian_file_metadata: { component: component_name }) + end + + scope :with_debian_architecture_name, ->(architecture_name) do + joins(:debian_file_metadatum) + .where(packages_debian_file_metadata: { architecture: architecture_name }) end scope :with_conan_package_reference, ->(conan_package_reference) do @@ -66,4 +80,4 @@ class Packages::PackageFile < ApplicationRecord end end -Packages::PackageFile.prepend_if_ee('EE::Packages::PackageFile') +Packages::PackageFile.prepend_mod_with('Packages::PackageFile') |