Sha256: 0b8642b845608bcd33595f244a32c4a074958cd0b61d89597305fe6dffc94f1f

Contents?: true

Size: 1.18 KB

Versions: 16

Compression:

Stored size: 1.18 KB

Contents

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

    self.table_name = 'katello_files'

    CONTENT_TYPE = Pulp::FileUnit::CONTENT_TYPE

    has_many :repositories, :through => :repository_files, :class_name => "Katello::Repository"
    has_many :repository_files, :class_name => "Katello::RepositoryFile", :dependent => :destroy, :inverse_of => :file, :foreign_key => :file_id

    scoped_search :on => :name, :complete_value => true
    scoped_search :on => :path, :complete_value => true
    scoped_search :on => :checksum
    scoped_search :relation => :repositories, :on => :name, :rename => :repository, :complete_value => true

    def self.default_sort
      order(:name)
    end

    def self.repository_association_class
      RepositoryFile
    end

    def self.unit_id_field
      'file_id'
    end

    def update_from_json(json)
      custom_json = {}
      custom_json['checksum'] = json['checksum']
      custom_json['path'] = json['name']
      custom_json['name'] = File.basename(json['name'])
      self.update_attributes!(custom_json)
    end

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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
katello-3.5.2 app/models/katello/file_unit.rb
katello-3.5.1.1 app/models/katello/file_unit.rb
katello-3.5.1 app/models/katello/file_unit.rb
katello-3.5.0.1 app/models/katello/file_unit.rb
katello-3.5.0 app/models/katello/file_unit.rb
katello-3.5.0.rc2 app/models/katello/file_unit.rb
katello-3.5.0.rc1 app/models/katello/file_unit.rb
katello-3.4.5 app/models/katello/file_unit.rb
katello-3.4.4 app/models/katello/file_unit.rb
katello-3.4.2 app/models/katello/file_unit.rb
katello-3.4.1 app/models/katello/file_unit.rb
katello-3.4.0.2 app/models/katello/file_unit.rb
katello-3.4.0.1 app/models/katello/file_unit.rb
katello-3.4.0 app/models/katello/file_unit.rb
katello-3.4.0.rc2 app/models/katello/file_unit.rb
katello-3.4.0.rc1 app/models/katello/file_unit.rb