-
Notifications
You must be signed in to change notification settings - Fork 294
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
Fixes #26226 - Filter Module Streams on CV #8295
Conversation
Issues: #26226 |
@parthaa I tried quick glance today for UI, found some issues mentioned below. Module Stream Link with not shown here. Module Stream Count shown wrong after all modules are applied in exclude filter with having Solve Dependencies is 'Yes'. This is not reproducible if Solve Dependencies is 'No'. We can get rid of this message as we have module stream filters Currently, Publishing content views is failing with the below steps
Minor UI Issue, while removing module stream list we are showing multiple success message not similar while adding. we should stick only UI success message? I will be testing this further in detailed. |
0f1b053
to
63649e3
Compare
@parthaa One More thing, I was not able to create the content view filter rule. tried some options, can you please that as well.
|
@omkarkhatavkar I think this should be a separate hammer bug. The --module-streams parameter in the api creates "multiple" rules - one for each module-stream.
|
63649e3
to
2816e87
Compare
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine. More guidelines are available in Coding Standards or on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
Make Sense, Bug raised here https://projects.theforeman.org/issues/27712 |
2816e87
to
8380fe9
Compare
There were the following issues with the commit message:
If you don't have a ticket number, please create an issue in Redmine. More guidelines are available in Coding Standards or on the Foreman wiki. This message was auto-generated by Foreman's prprocessor |
8380fe9
to
9c8ade3
Compare
addressed |
[test katello] |
@parthaa I saw today another issue really weird one |
PASS
Still Failing
PASS
PASS
Can be Ignored |
@partha: One change may be required here to make sure that API docs get updated
|
app/models/katello/module_stream.rb
Outdated
query | ||
end | ||
|
||
def self.uniquify_by_name_streams(name_streams) |
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.
where is this used?
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.
Good call. Going to remove it (left over stray method from the name/stream implementation).
f714a2e
to
e34745a
Compare
@parthaa please take a look on added automated tests for this PR here SatelliteQE/robottelo#7339 (whenever you get a chance) |
@parthaa I wonder if we need the description in the table of module streams in the filter? They can be lengthy and make the list very long and busy: |
@parthaa it looks like dependency solving does actually affect module streams? I'm guessing this is intended, if so, I think we should change some of the dep solving help text in the content view details page, new CV page, and settings page. It currently says: |
private | ||
|
||
def module_stream_arel | ||
::Katello::ModuleStream.arel_table |
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.
Why use arel in this file, does AR not provide the capability to do what you need?
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.
So this query is only generating the where clause, instead of hard coding "(item in 111,24,5)" as string I feel arel table is a better approach
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.
can't you do ::Katello::ModuleStream.find(module_stream_ids)
?
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.
Code and functionality looks good, just a few comments and open questions!
This commit adds UI, API and publish bindings for filtering module streams in a content view.
e34745a
to
ac4d96b
Compare
[test katlelo] |
[test katello] |
updated |
[test katello] |
@@ -82,7 +82,7 @@ <h2 translate>Create Content View</h2> | |||
</label> | |||
</div> | |||
<p class="help-block" translate> | |||
This will solve RPM dependencies on every publish of this Content View. Dependency solving significantly increases | |||
This will solve RPM and Module Stream dependencies on every publish of this Content View. Dependency solving significantly increases |
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.
This text is also in engines/bastion_katello/app/assets/javascripts/bastion_katello/content-views/details/views/content-view-info.html
, can you update there as well?
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.
updated
def generate_clauses(_repo) | ||
return if module_stream_rules.blank? | ||
|
||
module_stream_ids = module_stream_rules.map(&:module_stream_id) |
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.
module_stream_ids = module_stream_rules.map(&:module_stream_id) | |
module_stream_ids = module_stream_rules.map(&:module_stream_id) | |
::Katello::ModuleStream.find(module_stream_ids) unless module_stream_ids.empty? |
This is what I am thinking, but maybe I'm missing something
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.
Ok I can see why this is confusing. Check the following output on rails console
irb(main):005:0> ::Katello::ModuleStream.arel_table[:id].in([1,2,3]).to_sql
=> "\"katello_module_streams\".\"id\" IN (1, 2, 3)"
The contract for generate_clauses
is to return a sub clause like a where condition. Some thing like katello_module_streams in (...)
. This method returns the arel version. Some where down the line in ModuleClauseGenerator it actually does a to_sql
and aggregates various clauses with "or". Check out https://github.com/Katello/katello/pull/8295/files#diff-bba4518369114a7121b8027dac527bb1R56-R64
The main intent of generate clauses is to return \"katello_module_streams\".\"id\" IN (1, 2, 3)
" (a sub condition if you wll)
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.
@parthaa I get what you are doing here, but I'm still failing to see why all this logic is necessary. It's very possible that I'm overlooking some scenarios, I only poked around with basic examples.
Currently, it seems like a lot of hoops to jump through just to get a list of pulp ids from a list of module stream ids.
I tried something like this:
diff --git a/app/lib/katello/util/module_stream_clause_generator.rb b/app/lib/katello/util/module_stream_clause_generator.rb
index e67cc35..8a7d9f8 100644
--- a/app/lib/katello/util/module_stream_clause_generator.rb
+++ b/app/lib/katello/util/module_stream_clause_generator.rb
@@ -54,13 +54,11 @@ module Katello
end
def clauses_for_module_streams(module_stream_clauses = [])
- query_clauses = module_stream_clauses.map do |clause|
- "(#{clause.to_sql})"
- end
- return unless query_clauses.any?
+ ids = module_stream_clauses
+ return unless ids.any?
+ ids.flatten!
- statement = query_clauses.join(" OR ")
- {'_id' => { "$in" => ModuleStream.where(statement).pluck(:pulp_id)}}
+ {'_id' => { "$in" => ModuleStream.where(id: ids).pluck(:pulp_id)}}
end
end
end
diff --git a/app/models/katello/content_view_module_stream_filter.rb b/app/models/katello/content_view_module_stream_filter.rb
index f7803a2..ceca720 100644
--- a/app/models/katello/content_view_module_stream_filter.rb
+++ b/app/models/katello/content_view_module_stream_filter.rb
@@ -9,18 +9,7 @@ module Katello
def generate_clauses(_repo)
return if module_stream_rules.blank?
- module_stream_ids = module_stream_rules.map(&:module_stream_id)
- module_streams_in(module_stream_ids) unless module_stream_ids.empty?
- end
-
- private
-
- def module_stream_arel
- ::Katello::ModuleStream.arel_table
- end
-
- def module_streams_in(ids)
- module_stream_arel[:id].in(ids)
+ module_stream_rules.map(&:module_stream_id)
end
end
end
What is a basic example like the one above missing?
My main concern with using arel is I'm not sure how well Rails will support its API in upgrades and I would hate to see us cause headaches for ourselves down the road. Is there a way to do this without arel?
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.
addressed
I still want to continue the discussion about the arel clauses before approving, but otherwise, things look good and my other concerns are addressed 💯 |
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.
Works well!
This commit adds UI, API and publish bindings for filtering module
streams in a content view.
Check out https://partha.fedorapeople.org/CVModuleFilters/ for the screen shots