diff options
Diffstat (limited to 'app/models/concerns/packages')
-rw-r--r-- | app/models/concerns/packages/debian/distribution.rb | 9 | ||||
-rw-r--r-- | app/models/concerns/packages/destructible.rb | 15 | ||||
-rw-r--r-- | app/models/concerns/packages/installable.rb | 16 |
3 files changed, 40 insertions, 0 deletions
diff --git a/app/models/concerns/packages/debian/distribution.rb b/app/models/concerns/packages/debian/distribution.rb index ff52769fce8..2d46889ce6a 100644 --- a/app/models/concerns/packages/debian/distribution.rb +++ b/app/models/concerns/packages/debian/distribution.rb @@ -96,6 +96,15 @@ module Packages architectures.pluck(:name).sort end + def package_files + if Feature.enabled?(:packages_installable_package_files, default_enabled: :yaml) + ::Packages::PackageFile.installable + .for_package_ids(packages.select(:id)) + else + ::Packages::PackageFile.for_package_ids(packages.select(:id)) + end + end + private def unique_codename_and_suite diff --git a/app/models/concerns/packages/destructible.rb b/app/models/concerns/packages/destructible.rb new file mode 100644 index 00000000000..a3b7d8580c1 --- /dev/null +++ b/app/models/concerns/packages/destructible.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Packages + module Destructible + extend ActiveSupport::Concern + + class_methods do + def next_pending_destruction(order_by: nil) + set = pending_destruction.limit(1).lock('FOR UPDATE SKIP LOCKED') + set = set.order(order_by) if order_by + set.take + end + end + end +end diff --git a/app/models/concerns/packages/installable.rb b/app/models/concerns/packages/installable.rb new file mode 100644 index 00000000000..e9303e55412 --- /dev/null +++ b/app/models/concerns/packages/installable.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Packages + # This module requires a status column. + # It also requires a constant INSTALLABLE_STATUSES. This should be + # an array that defines which values of the status column are + # considered as installable. + module Installable + extend ActiveSupport::Concern + + included do + scope :with_status, ->(status) { where(status: status) } + scope :installable, -> { with_status(const_get(:INSTALLABLE_STATUSES, false)) } + end + end +end |