Skip to content

Commit

Permalink
Merge pull request #4208 from NickLaMuro/faster_report_result_display…
Browse files Browse the repository at this point in the history
…_fine

[FINE] Faster report result index pages
  • Loading branch information
simaishi authored Jun 26, 2018
2 parents 91f9ba5 + 02fd904 commit 99d3049
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def saved_report_paging
@sb[:pages][:perpage] = settings(:perpage, :reports)

rr = MiqReportResult.find(@sb[:pages][:rr_id])
@html = report_build_html_table(rr.report_results,
@html = report_build_html_table(rr.report,
rr.html_rows(:page => @sb[:pages][:current],
:per_page => @sb[:pages][:perpage]).join)

Expand Down
5 changes: 2 additions & 3 deletions app/controllers/chargeback_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -349,17 +349,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.valid_report_column?
@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?
@zgraph = 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 @@ -26,9 +26,8 @@ def 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.valid_report_column?
add_flash(_("Saved Report \"%{time}\" not found, Schedule may have failed") %
{:time => format_timezone(rr.created_on, Time.zone, "gtl")},
:error)
Expand All @@ -48,7 +47,7 @@ def fetch_saved_report(id)
end
return
else
if @report.contains_records?
if rr.contains_records?
@html = report_first_page(rr) # Get the first page of the results
if params[:type]
@zgraph = nil
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ApplicationHelper::Button::ReportDownloadChoice < ApplicationHelper::Button::Basic
def disabled?
MiqReportResult.find(@report_result_id).try(:miq_report_result_details).try(:length).to_i == 0
!MiqReportResult.find(@report_result_id).try(:miq_report_result_details).try(:exists?)
end
end
2 changes: 1 addition & 1 deletion app/helpers/application_helper/button/report_only.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ def disabled?

def report_records?
@report.present? && @report_result_id.present? &&
MiqReportResult.find(@report_result_id).try(:miq_report_result_details).try(:length).to_i > 0
MiqReportResult.find(@report_result_id).try(:miq_report_result_details).try(:exists?)
end
end
3 changes: 2 additions & 1 deletion spec/controllers/chargeback_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,8 @@ def convert_chargeback_rate_to_hash(rate)
miq_task.state_finished
miq_report_result.report = chargeback_report.to_hash.merge(:extras=> {:total_html_rows => 100})
miq_report_result.save
allow(controller).to receive(:report_first_page)
controller.instance_variable_set(:@sb, {})
controller.instance_variable_set(:@settings, :perpage => { :reports => 20 })
end

it "fetch existing report" do
Expand Down
9 changes: 6 additions & 3 deletions spec/controllers/miq_report_controller/trees_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@
before do
login_as user
controller.instance_variable_set(:@html, "<h1>Test</h1>")
allow(controller).to receive(:report_first_page)
allow(report).to receive(:contains_records?).and_return(true)
allow_any_instance_of(MiqReportResult).to receive(:report_results).and_return(report)
session[:settings] = {:perpage => {:reports => 20}}
report_result.report = report.to_hash.merge(:extras=> {:total_html_rows => 100})
report_result.save
# allow(controller).to receive(:report_first_page)
# allow(report).to receive(:contains_records?).and_return(true)
# allow_any_instance_of(MiqReportResult).to receive(:report_results).and_return(report)
end

it 'renders show from CI -> Reports -> Saved Reports' do
Expand Down

0 comments on commit 99d3049

Please sign in to comment.