Skip to content

Commit afc66ab

Browse files
[api] render only matching products in binary search
but include version information now
1 parent 65c674f commit afc66ab

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/api/app/models/binary_release.rb

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,12 @@ def update_for_product
2525
self.repository.product_update_repositories.map{ |i| i.product if i.product }
2626
end
2727

28-
def on_product_medium
29-
self.repository.product_medium
28+
def product_medium
29+
self.repository.product_medium.where(name: medium).first
3030
end
3131

32-
# def on_product_medium
33-
# return [] unless medium
34-
# self.repository.product_medium.where("repository.product_medium.name" => medium).map{ |i| i.product if i.product }
35-
# end
36-
3732
def render_attributes
33+
# renders all values, which are used as identifier of a binary entry.
3834
p = { :project => repository.project.name,
3935
:repository => repository.name,
4036
}
@@ -71,8 +67,17 @@ def render_xml
7167
b.updatefor(project: up.package.project.name, product: up.name)
7268
end
7369

74-
on_product_medium.uniq.each do |opm|
75-
b.product(project: opm.product.package.project.name, name: opm.product.name, medium: opm.name)
70+
if self.product_medium
71+
product = self.product_medium.product
72+
h = {project: product.package.project.name, name: product.name}
73+
if product.baseversion
74+
h[:baseversion] = product.baseversion
75+
h[:patchlevel] = product.patchlevel
76+
else
77+
h[:version] = product.version
78+
end
79+
h[:release] = product.release if product.release
80+
b.product(h)
7681
end
7782

7883
end

src/api/test/functional/binary_release_test.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def test_search_binary_release_in_fixtures
7070
assert_response :success
7171
assert_xml_tag :tag => "binary", :attributes => { :project => "BaseDistro3", :repository => "BaseDistro3_repo", :name => "package", :version => "1.0", :release => "1", :arch => "i586", :medium => "DVD"}
7272
assert_xml_tag :tag => "updatefor", :attributes => { project: "BaseDistro", product: "fixed" }
73-
assert_xml_tag :tag => "product", :attributes => { project: "BaseDistro", name: "fixed", medium: "DVD" }
73+
assert_xml_tag :tag => "product", :attributes => { project: "BaseDistro", name: "fixed", version: "1.2" }
7474
get '/search/released/binary', match: "product/[@project = 'BaseDistro' and @name = 'fixed' and @medium = 'DVD']"
7575
assert_response :success
7676
assert_xml_tag :tag => "binary", :attributes => { :project => "BaseDistro3", :repository => "BaseDistro3_repo", :name => "package", :version => "1.0", :release => "1", :arch => "i586", :medium => "DVD"}
@@ -86,7 +86,7 @@ def test_search_binary_release_in_fixtures
8686
assert_response :success
8787
assert_xml_tag :tag => "binary", :attributes => { :project => "BaseDistro3", :repository => "BaseDistro3_repo", :name => "package", :version => "1.0", :release => "1", :arch => "i586"}
8888
assert_xml_tag :tag => "updatefor", :attributes => { project: "BaseDistro", product: "fixed" }
89-
assert_xml_tag :tag => "product", :attributes => { project: "BaseDistro", name: "fixed", medium: "DVD" }
89+
assert_xml_tag :tag => "product", :attributes => { project: "BaseDistro", name: "fixed", version: "1.2" }
9090

9191
end
9292

0 commit comments

Comments
 (0)