-
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
Conversation
@@ -416,6 +416,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 comment
The 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 comment
The 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.
2f644ba
to
7460b26
Compare
98ed006
to
6aa07b8
Compare
This pull request is not mergeable. Please rebase and repush. |
6aa07b8
to
53ab8cf
Compare
53ab8cf
to
93db3a1
Compare
@miq-bot rm-label wip |
93db3a1
to
33a722b
Compare
Checked commits imtayadeway/manageiq@639ee18~...33a722b with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
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.
Looks awesome 👍
@@ -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) |
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
for entitlement
. In practice, every group should have an entitlement. Since removing the try
will cause tests to fail, this can be done in a followup PR.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Should the the Entitlement
model enforce setting only one of expression
or user_filters
?
@@ -416,6 +416,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 comment
The 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.
Just opening as a wip for discussion
@gtanzillo this needs a few more test cases and a more general solution, but opening so we can discuss a few problem areas
@miq-bot add-label core, enhancement, wip
@miq-bot assign @gtanzillo
Resolves https://www.pivotaltracker.com/story/show/148794877