Skip to content

Commit

Permalink
Prefer has_report? and contains_records? from MiqReportResult
Browse files Browse the repository at this point in the history
These are new methods added in:

ManageIQ/manageiq#17590

And are for more efficient for the use cases of ChargebackController and
ReportController::SavedReports.
  • Loading branch information
NickLaMuro committed Jun 14, 2018
1 parent e3c4096 commit 33266f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions app/controllers/chargeback_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -345,17 +345,16 @@ def cb_rpts_fetch_saved_report(id)
@report_result_id = session[:report_result_id] = rr.id
session[:report_result_runtime] = rr.last_run_on
if rr.status.downcase == "complete"
@report = rr.report_results
session[:rpt_task_id] = nil
if @report.blank?
unless rr.has_report?
@saved_reports = cb_rpts_get_all_reps(rr.miq_report_id.to_s)
rep = MiqReport.find_by_id(rr.miq_report_id)
if x_active_tree == :cb_reports_tree
self.x_node = "reports-#{rep.id}"
end
return
else
if @report.contains_records?
if rr.contains_records?
@html = report_first_page(rr) # Get the first page of the results
unless @report.graph.blank?
@render_chart = true
Expand Down
5 changes: 2 additions & 3 deletions app/controllers/report_controller/saved_reports.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ def fetch_saved_report(id)

return unless rr.status.downcase == "complete"

@report = rr.report_results
session[:rpt_task_id] = nil

if @report.blank?
unless rr.has_report?
add_flash(_("Saved Report \"%{time}\" not found, Schedule may have failed") %
{:time => format_timezone(rr.created_on, Time.zone, "gtl")},
:error)
Expand All @@ -56,7 +55,7 @@ def fetch_saved_report(id)
return
end

unless @report.contains_records?
unless rr.contains_records?
add_flash(_("No records found for this report"), :warning)
return
end
Expand Down

0 comments on commit 33266f3

Please sign in to comment.