Sha256: 34b387b341597e7bb7c70564ea2339756a17d0010daa36348b1958e68704bc33

Contents?: true

Size: 1.18 KB

Versions: 14

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 :repository_files, :class_name => "Katello::RepositoryFile", :dependent => :destroy, :inverse_of => :file, :foreign_key => :file_id
    has_many :repositories, :through => :repository_files, :class_name => "Katello::Repository"

    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).count
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
katello-3.8.1 app/models/katello/file_unit.rb
katello-3.7.1.1 app/models/katello/file_unit.rb
katello-3.7.1 app/models/katello/file_unit.rb
katello-3.8.0 app/models/katello/file_unit.rb
katello-3.8.0.rc3 app/models/katello/file_unit.rb
katello-3.8.0.rc2 app/models/katello/file_unit.rb
katello-3.7.0 app/models/katello/file_unit.rb
katello-3.8.0.rc1 app/models/katello/file_unit.rb
katello-3.7.0.rc2 app/models/katello/file_unit.rb
katello-3.7.0.rc1 app/models/katello/file_unit.rb
katello-3.6.0 app/models/katello/file_unit.rb
katello-3.6.0.1.rc2 app/models/katello/file_unit.rb
katello-3.6.0.rc2 app/models/katello/file_unit.rb
katello-3.6.0.rc1 app/models/katello/file_unit.rb