Skip to content
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 faster MiqReportResult helper methods for viewing saved report results #17590

Merged
merged 2 commits into from
Jun 18, 2018

Conversation

NickLaMuro
Copy link
Member

@NickLaMuro NickLaMuro commented Jun 14, 2018

Adds two methods:

  • MiqReportResult#has_report?
  • MiqReportResult#contains_records?

This is specifically used to avoid having to fetch and deserialize the binary_blob associated with the MiqReportResult, which has the entire Ruport::Data::Table object saved in it, and eventually is never used in some of the controllers that make use of them.

MiqReportResult#has_report?

A quicker check than having to use MiqReportResult#report_results, since binary_blob doesn't need to be loaded into memory. On top of that, generally the binary_blob.data isn't even used in the controller at the end of the day, and this version of the MiqReport record ends up being what is used when generating the page for viewing.

MiqReportResult#contains_records?

Like MiqReportResult#has_report?, this is a faster version of checking if the report_result has rows.

Like MiqReport#contains_records?, this will check against the extras attribute on the deserialized version of the report column, but instead of using the table value (which is not saved into the report column), just do a light SQL existence check on the html_details to confirm there are generated rows for this report.

The SQL query most likely won't be needed, and it is super light weight, only returning a single digit, or an empty result set if there are no records.

Links

Will put benchmarks in the associated UI PR.

NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Jun 14, 2018
These are new methods added in:

ManageIQ/manageiq#17590

And are for more efficient for the use cases of ChargebackController and
ReportController::SavedReports.
# Use this method over `report_results` if you don't plan on using the
# `binary_blob` associated with the MiqReportResult (chances are you don't
# need it).
def has_report?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the cop suggestion of report? What do you think ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Honestly, I was thinking about this and want to make this "more verbose". report?, and even has_report? gives the impression that report is a relation, not a column on this report. I am almost thinking of renaming this to valid_report_column? or something like that.

Thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, good point... why would report not be a MiqReport? It seems like the report result might be useless without a report object... but I'm not sure how it's used if there isn't a report. Maybe linked_report? since the UI use case you changed is to change the selected node in the chargeback tree for the report corresponding to this report result.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this is a serialized report shoved into the report column, so it could be serialized to anything technically speaking.

linked_report? to me still sounds like we are talking about a relation, when in fact, this is part of the record itself. Does that rational make sense?

@jrafanie
Copy link
Member

Kicked travis. Other than the method naming, I'm good with these changes.

@jrafanie
Copy link
Member

@NickLaMuro you might want to put the bz link in the commits so the bz becomes self documenting when the commits get merged and copied to the bz automagically by the bot. I document my commits as if they are going directly to the BZ so testing/recreation steps are all there.

@NickLaMuro
Copy link
Member Author

@NickLaMuro you might want to put the bz link in the commits so the bz becomes self documenting when the commits get merged and copied to the bz automagically by the bot.

Yeah, that makes sense I guess. Will do.

NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Jun 15, 2018
https://bugzilla.redhat.com/show_bug.cgi?id=1590908

These are new methods added in:

ManageIQ/manageiq#17590

And are for more efficient for the use cases of ChargebackController and
ReportController::SavedReports.
@jrafanie
Copy link
Member

@NickLaMuro any idea why this is failing the chargeback tests? Are they calling these new methods???

@NickLaMuro
Copy link
Member Author

NickLaMuro commented Jun 18, 2018

@jrafanie Unsure, but when I looked, it seemed like the test failures were benign and unrelated. I will look again though, just to be sure.

https://bugzilla.redhat.com/show_bug.cgi?id=1590908

A quicker check than having to use `MiqReportResult#report_results`,
since binary_blob doesn't need to be loaded into memory.  On top of
that, generally the binary_blob.data isn't even used in the controller
at the end of the day, and this version of the MiqReport record ends up
being what is used when generating the page for viewing.
https://bugzilla.redhat.com/show_bug.cgi?id=1590908

Like `MiqReportResult#has_report?`, this is a faster version of checking
if the report_result has rows.

Like `MiqReport#contains_records?`, this will check against the `extras`
attribute on the deserialized version of the `report` column, but
instead of using the `table` value (which is not saved into the `report`
column), just do a light SQL existence check on the `html_details` to
confirm there are generated rows for this report.

The SQL query most likely won't be needed, and it is super light weight,
only returning a single digit, or an empty result set if there are no
records.
@miq-bot
Copy link
Member

miq-bot commented Jun 18, 2018

Checked commits NickLaMuro/manageiq@6b2e57d~...3a26db0 with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0
1 file checked, 0 offenses detected
Everything looks fine. ⭐

@jrafanie jrafanie added this to the Sprint 88 Ending Jun 18, 2018 milestone Jun 18, 2018
@jrafanie
Copy link
Member

@NickLaMuro can you add labels to match the other one for the bz?

@jrafanie jrafanie merged commit dbf6596 into ManageIQ:master Jun 18, 2018
@jrafanie jrafanie self-assigned this Jun 18, 2018
@NickLaMuro
Copy link
Member Author

@miq-bot blocker, gaprindashvili/yes

@miq-bot
Copy link
Member

miq-bot commented Jun 18, 2018

@NickLaMuro unrecognized command 'blocker', ignoring...

Accepted commands are: add_label, add_reviewer, assign, close_issue, move_issue, remove_label, rm_label, set_milestone

@NickLaMuro
Copy link
Member Author

...

@miq-bot add_label blocker, gaprindashvili/yes

NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Jun 18, 2018
https://bugzilla.redhat.com/show_bug.cgi?id=1590908

These are new methods added in:

ManageIQ/manageiq#17590

And are for more efficient for the use cases of ChargebackController and
ReportController::SavedReports.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Jun 18, 2018
https://bugzilla.redhat.com/show_bug.cgi?id=1590908

These are new methods added in:

ManageIQ/manageiq#17590

And are for more efficient for the use cases of ChargebackController and
ReportController::SavedReports.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Jun 19, 2018
https://bugzilla.redhat.com/show_bug.cgi?id=1590908

These are new methods added in:

ManageIQ/manageiq#17590

And are far more efficient for the use cases of ChargebackController and
ReportController::SavedReports.
@jrafanie
Copy link
Member

@miq-bot add_label fine/yes

simaishi pushed a commit that referenced this pull request Jun 22, 2018
Add faster MiqReportResult helper methods for viewing saved report results
(cherry picked from commit dbf6596)

https://bugzilla.redhat.com/show_bug.cgi?id=1594387
@simaishi
Copy link
Contributor

Fine backport details:

$ git log -1
commit d1177fd98c4f3fbc1825c9a432bb92017bc99d6e
Author: Joe Rafaniello <jrafanie@users.noreply.github.com>
Date:   Mon Jun 18 15:05:17 2018 -0400

    Merge pull request #17590 from NickLaMuro/faster_saved_report_methods
    
    Add faster MiqReportResult helper methods for viewing saved report results
    (cherry picked from commit dbf6596ca6903a4c7d30cc16fe9f137db9a6a026)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1594387

simaishi pushed a commit that referenced this pull request Jun 22, 2018
Add faster MiqReportResult helper methods for viewing saved report results
(cherry picked from commit dbf6596)

https://bugzilla.redhat.com/show_bug.cgi?id=1594386
@simaishi
Copy link
Contributor

Gaprindashvili backport details:

$ git log -1
commit ee76f422c42f513122f0a379ea8c70bc65804cef
Author: Joe Rafaniello <jrafanie@users.noreply.github.com>
Date:   Mon Jun 18 15:05:17 2018 -0400

    Merge pull request #17590 from NickLaMuro/faster_saved_report_methods
    
    Add faster MiqReportResult helper methods for viewing saved report results
    (cherry picked from commit dbf6596ca6903a4c7d30cc16fe9f137db9a6a026)
    
    https://bugzilla.redhat.com/show_bug.cgi?id=1594386

NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Jun 25, 2018
https://bugzilla.redhat.com/show_bug.cgi?id=1590908

These are new methods added in:

ManageIQ/manageiq#17590

And are far more efficient for the use cases of ChargebackController and
ReportController::SavedReports.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Jun 25, 2018
https://bugzilla.redhat.com/show_bug.cgi?id=1594386

Gaprindashvili Backport commit from:

    ManageIQ#4143

Original SHA:

   ff7ee24

Rest of original message below...

* * *

These are new methods added in:

ManageIQ/manageiq#17590

And are far more efficient for the use cases of ChargebackController and
ReportController::SavedReports.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Jun 25, 2018
https://bugzilla.redhat.com/show_bug.cgi?id=1594387

Gaprindashvili Backport commit from:

    ManageIQ#4143

Original SHA:

   ff7ee24

Rest of original message below...

* * *

These are new methods added in:

ManageIQ/manageiq#17590

And are far more efficient for the use cases of ChargebackController and
ReportController::SavedReports.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Jun 25, 2018
…rtResult

https://bugzilla.redhat.com/show_bug.cgi?id=1594387

Gaprindashvili Backport commit from:

    ManageIQ#4143

Original SHA:

   ff7ee24

Rest of original message below...

* * *

These are new methods added in:

ManageIQ/manageiq#17590

And are far more efficient for the use cases of ChargebackController and
ReportController::SavedReports.
NickLaMuro added a commit to NickLaMuro/manageiq-ui-classic that referenced this pull request Jun 25, 2018
…tResult

https://bugzilla.redhat.com/show_bug.cgi?id=1594386

Gaprindashvili Backport commit from:

    ManageIQ#4143

Original SHA:

   ff7ee24

Rest of original message below...

* * *

These are new methods added in:

ManageIQ/manageiq#17590

And are far more efficient for the use cases of ChargebackController and
ReportController::SavedReports.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants