Class: Katello::Deb
- Includes:
- Concerns::PulpDatabaseUnit
- Defined in:
- app/models/katello/deb.rb
Constant Summary collapse
- CONTENT_TYPE =
'deb'.freeze
Class Method Summary collapse
- .applicable_to_hosts(hosts) ⇒ Object
- .content_facet_association_class ⇒ Object
- .default_sort ⇒ Object
- .installable_for_hosts(hosts = nil) ⇒ Object
- .latest(_relation) ⇒ Object
- .repository_association_class ⇒ Object
- .search_version_equal(version) ⇒ Object
- .search_version_range(min = nil, max = nil) ⇒ Object
- .split_nav(value) ⇒ Object
- .total_for_repositories(repos) ⇒ Object
Instance Method Summary collapse
- #hosts_applicable(org_id = nil) ⇒ Object
- #hosts_available(org_id = nil) ⇒ Object
-
#nav ⇒ Object
the format apt needs to identify the packet with version and architecture.
-
#nva ⇒ Object
the more natural format ;-).
Methods included from Concerns::PulpDatabaseUnit
#backend_data, #library_repositories, #remove_from_repository
Methods inherited from Model
Class Method Details
.applicable_to_hosts(hosts) ⇒ Object
93 94 95 96 |
# File 'app/models/katello/deb.rb', line 93 def self.applicable_to_hosts(hosts) self.joins(:content_facets). where("#{Katello::Host::ContentFacet.table_name}.host_id" => hosts).distinct end |
.content_facet_association_class ⇒ Object
27 28 29 |
# File 'app/models/katello/deb.rb', line 27 def self.content_facet_association_class ContentFacetApplicableDeb end |
.default_sort ⇒ Object
19 20 21 |
# File 'app/models/katello/deb.rb', line 19 def self.default_sort order(:name).order(:version).order(:architecture) end |
.installable_for_hosts(hosts = nil) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/models/katello/deb.rb', line 77 def self.installable_for_hosts(hosts = nil) debs = Katello::Deb.joins(:repositories, "INNER JOIN #{Katello::InstalledDeb.table_name} ON #{Katello::InstalledDeb.table_name}.name = #{self.table_name}.name", "INNER JOIN #{Katello::HostInstalledDeb.table_name} ON #{Katello::HostInstalledDeb.table_name}.installed_deb_id = #{Katello::InstalledDeb.table_name}.id") .where("deb_version_cmp(#{self.table_name}.version, #{Katello::InstalledDeb.table_name}.version) > 0") unless hosts.nil? facet_repos = Katello::ContentFacetRepository.joins(:content_facet => :host).select(:repository_id) hosts = ::Host.where(id: hosts) if hosts.is_a?(Array) facet_repos = facet_repos.merge(hosts).reorder(nil) debs = debs.where("#{Katello::HostInstalledDeb.table_name}.host_id": hosts.pluck(:id)) .where("#{Katello::RepositoryDeb.table_name}.repository_id" => facet_repos) end debs.distinct end |
.latest(_relation) ⇒ Object
98 99 100 |
# File 'app/models/katello/deb.rb', line 98 def self.latest(_relation) fail 'NotImplemented' end |
.repository_association_class ⇒ Object
23 24 25 |
# File 'app/models/katello/deb.rb', line 23 def self.repository_association_class RepositoryDeb end |
.search_version_equal(version) ⇒ Object
38 39 40 |
# File 'app/models/katello/deb.rb', line 38 def self.search_version_equal(version) Katello::Util::PackageFilter.new(self, version, Katello::Util::PackageFilter::EQUAL).results end |
.search_version_range(min = nil, max = nil) ⇒ Object
31 32 33 34 35 36 |
# File 'app/models/katello/deb.rb', line 31 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 |
.split_nav(value) ⇒ Object
56 57 58 59 60 61 |
# File 'app/models/katello/deb.rb', line 56 def self.split_nav(value) v = /^(?<name>[^:\s]+)(:(?<architecture>[^=\s]*))?(=(?<version>.*))?$/.match(value)&.named_captures if v [ v['name'], v['architecture'], v['version'] ] end end |
.total_for_repositories(repos) ⇒ Object
42 43 44 |
# File 'app/models/katello/deb.rb', line 42 def self.total_for_repositories(repos) self.in_repositories(repos).count end |
Instance Method Details
#hosts_applicable(org_id = nil) ⇒ Object
63 64 65 66 67 68 69 |
# File 'app/models/katello/deb.rb', line 63 def hosts_applicable(org_id = nil) if org_id.present? self.content_facets.joins(:host).where("#{::Host.table_name}.organization_id" => org_id) else self.content_facets.joins(:host) end end |
#hosts_available(org_id = nil) ⇒ Object
71 72 73 74 75 |
# File 'app/models/katello/deb.rb', line 71 def hosts_available(org_id = nil) self.hosts_applicable(org_id).joins("INNER JOIN #{Katello::RepositoryDeb.table_name} on \ #{Katello::RepositoryDeb.table_name}.deb_id = #{self.id}").joins(:content_facet_repositories). where("#{Katello::ContentFacetRepository.table_name}.repository_id = #{Katello::RepositoryDeb.table_name}.repository_id").uniq end |
#nav ⇒ Object
the format apt needs to identify the packet with version and architecture
47 48 49 |
# File 'app/models/katello/deb.rb', line 47 def nav "#{self.name}:#{self.architecture}=#{self.version}" end |
#nva ⇒ Object
the more natural format ;-)
52 53 54 |
# File 'app/models/katello/deb.rb', line 52 def nva "#{self.name}_#{self.version}_#{self.architecture}" end |