-
Notifications
You must be signed in to change notification settings - Fork 898
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
Add MiqExpression support for managed filters #15623
Changes from all commits
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 |
---|---|---|
|
@@ -351,9 +351,11 @@ def get_self_service_objects(user, miq_group, klass) | |
|
||
def calc_filtered_ids(scope, user_filters, user, miq_group, scope_tenant_filter) | ||
klass = scope.respond_to?(:klass) ? scope.klass : scope | ||
expression = miq_group.try(:entitlement).try(:filter_expression) | ||
expression.set_tagged_target(klass) if expression | ||
u_filtered_ids = pluck_ids(get_self_service_objects(user, miq_group, klass)) | ||
b_filtered_ids = get_belongsto_filter_object_ids(klass, user_filters['belongsto']) | ||
m_filtered_ids = pluck_ids(get_managed_filter_object_ids(scope, user_filters['managed'])) | ||
m_filtered_ids = pluck_ids(get_managed_filter_object_ids(scope, expression || user_filters['managed'])) | ||
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. Should the the |
||
d_filtered_ids = pluck_ids(matches_via_descendants(rbac_class(klass), user_filters['match_via_descendants'], | ||
:user => user, :miq_group => miq_group)) | ||
|
||
|
@@ -417,6 +419,7 @@ def get_belongsto_filter_object_ids(klass, filter) | |
end | ||
|
||
def get_managed_filter_object_ids(scope, filter) | ||
return scope.where(filter.to_sql.first) if filter.kind_of?(MiqExpression) | ||
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. this MiqExpression will be always convertible to sql ? 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. @lpichler, yes, these expressions will be limited to tags on the main class only and will always be convertible to SQL. |
||
klass = scope.respond_to?(:klass) ? scope.klass : scope | ||
return nil if !TAGGABLE_FILTER_CLASSES.include?(safe_base_class(klass).name) || filter.blank? | ||
scope.find_tags_by_grouping(filter, :ns => '*').reorder(nil) | ||
|
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.
You probably don't need the
try
forentitlement
. In practice, every group should have an entitlement. Since removing thetry
will cause tests to fail, this can be done in a followup PR.