Skip to content

Commit

Permalink
Fixes #33525 - Add debs packages_restrict_latest
Browse files Browse the repository at this point in the history
  • Loading branch information
m-bucher committed Sep 27, 2021
1 parent f3ab52f commit 93a1677
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/controllers/katello/api/v2/debs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def auto_complete_arch
param :host_id, :number, :desc => N_("Host id to list applicable deb packages for")
param :packages_restrict_applicable, :boolean, :desc => N_("Return deb packages that are applicable to one or more hosts (defaults to true if host_id is specified)")
param :packages_restrict_upgradable, :boolean, :desc => N_("Return deb packages that are upgradable on one or more hosts")
param :packages_restrict_latest, :boolean, :desc => N_("Return only the latest version of each package")
param :available_for, String, :desc => N_("Return deb packages that can be added to the specified object. Only the value 'content_view_version' is supported.")
param_group :search, ::Katello::Api::V2::ApiController
def index
Expand Down
5 changes: 4 additions & 1 deletion app/models/katello/deb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ def self.applicable_to_hosts(hosts)
end

def self.latest(_relation)
fail 'NotImplemented'
return relation.joins(
"LEFT JOIN (#{relation.to_sql}) AS katello_debs2 ON " \
'katello_debs.name=katello_debs2.name AND deb_version_cmp(katello_debs.version,katello_debs2.version) < 0'
).where('katello_debs2.version IS NULL')
end
end
end

0 comments on commit 93a1677

Please sign in to comment.