Make some _reports_menu methods a little more readable #5501
+17
−9
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Using the
MiqReport.for_user
method is not necessary for thedefault_reports_menu
at all, as it only requests theDefault
reports regardless of the current user. I also expanded the code to more lines with some comments to make it easier to read.Retrieving the custom reports in
get_reports_menu
can be also simplified by dropping theMiqReport.for_user
and just asking for the reports for that one given group, instead of all groups of the user and then filtering. If the user have global access to all custom reports, thegroup_id
is simply not passed to thewhere
hash.Ideally I'd like to extract these things into named scopes or at least class methods into the
MiqGroup
orMiqReport
models, but first let's simplify them.@miq-bot add_label refactoring, hammer/no, reporting
@miq-bot add_reviewer @mzazrivec
@miq-bot add_reviewer @h-kataria