Sha256: 8c6fcbf343f636aed3a1e3fa74753e6f656675bed6f64e6cd397ed05b0301155

Contents?: true

Size: 1.71 KB

Versions: 29

Compression:

Stored size: 1.71 KB

Contents

module Katello
  class Deb < Katello::Model
    include Concerns::PulpDatabaseUnit

    CONTENT_TYPE = Pulp::Deb::CONTENT_TYPE

    has_many :repositories, :through => :repository_debs, :class_name => "Katello::Repository"
    has_many :repository_debs, :class_name => "Katello::RepositoryDeb", :dependent => :destroy, :inverse_of => :deb

    scoped_search :on => :name, :complete_value => true
    scoped_search :on => :version, :complete_value => true
    scoped_search :on => :architecture, :complete_value => true
    scoped_search :on => :filename, :complete_value => true
    scoped_search :on => :checksum

    before_save lambda { |deb| deb.description = deb.description.truncate(255) unless deb.description.blank? }

    def self.default_sort
      order(:name).order(:version).order(:architecture)
    end

    def self.repository_association_class
      RepositoryDeb
    end

    def self.search_version_range(min = nil, max = nil)
      query = self.all
      query = Katello::Util::PackageFilter.new(query, min, Katello::Util::PackageFilter::GREATER_THAN).results if min
      query = Katello::Util::PackageFilter.new(query, max, Katello::Util::PackageFilter::LESS_THAN).results if max
      query
    end

    def self.search_version_equal(version)
      Katello::Util::PackageFilter.new(self, version, Katello::Util::PackageFilter::EQUAL).results
    end

    def update_from_json(json)
      keys = Pulp::Deb::PULP_INDEXED_FIELDS - ['_id']
      custom_json = json.slice(*keys)
      if custom_json.any? { |name, value| self.send(name) != value }
        self.assign_attributes(custom_json)
        self.save!
      end
    end

    def self.total_for_repositories(repos)
      self.in_repositories(repos).count
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
katello-3.11.2 app/models/katello/deb.rb
katello-3.10.2 app/models/katello/deb.rb
katello-3.10.1.1 app/models/katello/deb.rb
katello-3.10.1 app/models/katello/deb.rb
katello-3.11.1 app/models/katello/deb.rb
katello-3.11.0 app/models/katello/deb.rb
katello-3.11.0.rc2 app/models/katello/deb.rb
katello-3.11.0.rc1 app/models/katello/deb.rb
katello-3.10.0 app/models/katello/deb.rb
katello-3.10.0.rc1.1 app/models/katello/deb.rb
katello-3.9.1 app/models/katello/deb.rb
katello-3.10.0.rc1 app/models/katello/deb.rb
katello-3.9.0 app/models/katello/deb.rb
katello-3.8.1 app/models/katello/deb.rb
katello-3.9.0.rc2 app/models/katello/deb.rb
katello-3.9.0.rc1 app/models/katello/deb.rb
katello-3.7.1.1 app/models/katello/deb.rb
katello-3.7.1 app/models/katello/deb.rb
katello-3.8.0 app/models/katello/deb.rb
katello-3.8.0.rc3 app/models/katello/deb.rb