-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SLE15 product tree support -- 4702 #72
Changes from all commits
84dd088
f022bcd
c5eed3a
df59f3a
07520c7
61663f7
d1ffc94
80e6d50
b6543e7
57e9038
10bed41
74a495f
1b9e50e
0499743
dcfa1aa
629adfd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,11 +11,12 @@ def repositories | |
end | ||
|
||
attributes :id, :name, :identifier, :former_identifier, :version, :release_type, :arch, | ||
:friendly_name, :product_class, :cpe, :free, :description, :eula_url, :repositories, :product_type, :extensions | ||
:friendly_name, :product_class, :cpe, :free, :description, :eula_url, :repositories, :product_type, | ||
:extensions, :recommended, :available | ||
|
||
def extensions | ||
object.mirrored_extensions.map do |extension| | ||
::V3::ProductSerializer.new(extension, base_url: base_url).attributes | ||
object.extensions.for_root_product(root_product).map do |extension| | ||
::V3::ProductSerializer.new(extension, base_url: base_url, root_product: root_product).attributes | ||
end | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In glue we simply have a has_many :extensions, serializer: V3::ProductSerializer
def extensions
object.extensions.for_root_product(root_product)
end There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I remember I was looking into this at the very beginning and the current code is the solution that works correctly. The problem is that for some reason it doesn't serialize all of the attributes of the relation, namely the ones that are declared on the serializer and don't exist on the model (like If you have any idea what's going on with that -- feel free to share. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm weird, |
||
end | ||
|
||
|
@@ -37,4 +38,17 @@ def free | |
true | ||
end | ||
|
||
def root_product | ||
@instance_options[:root_product] ||= object | ||
end | ||
|
||
def recommended | ||
object.recommended_for? root_product | ||
end | ||
|
||
# This attribute is added by SMT as well, indicating whether the product is mirrored or not | ||
def available | ||
object.mirror? | ||
end | ||
|
||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
class AddRootAndRecommendedToProductsExtensions < ActiveRecord::Migration[5.1] | ||
|
||
def change | ||
add_column :products_extensions, :recommended, :boolean | ||
add_column :products_extensions, :root_product_id, :integer | ||
add_index :products_extensions, %i[product_id extension_id root_product_id], | ||
unique: true, name: 'index_products_extensions_on_product_extension_root' | ||
|
||
reversible do |dir| | ||
dir.up do | ||
ProductsExtensionsAssociation.find_each.each do |pa| | ||
base = pa.product | ||
pa.root_product = base.bases.present? ? base.bases.first : base | ||
pa.recommended = false | ||
pa.save! | ||
end | ||
change_column_null(:products_extensions, :root_product_id, false) | ||
end | ||
end | ||
end | ||
|
||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're missing unit tests for this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, it was covered only by serializer specs. I've added a test for this method.