Bugzilla – Attachment 93723 Details for
Bug 23626
Add a system preference to limit the number of rows of data used when charting or exporting report results
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 23626: [alternate] Only fetch full chart data if requested
Bug-23626-alternate-Only-fetch-full-chart-data-if-.patch (text/plain), 8.57 KB, created by
Biblibre Sandboxes
on 2019-10-04 09:27:34 UTC
(
hide
)
Description:
Bug 23626: [alternate] Only fetch full chart data if requested
Filename:
MIME Type:
Creator:
Biblibre Sandboxes
Created:
2019-10-04 09:27:34 UTC
Size:
8.57 KB
patch
obsolete
>From 7b1380c9f0520d3333d5dc7b532f37f90ef64249 Mon Sep 17 00:00:00 2001 >From: Nick <nick@bywatersolutions.com> >Date: Wed, 2 Oct 2019 09:58:59 +0000 >Subject: [PATCH] Bug 23626: [alternate] Only fetch full chart data if > requested >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patchset prevents the full return of report data unless explicitly requested by the user for charting purposes >Additionally the user is warned if requesting more than 1000 rows of data > >To test: > 1 - Create a report that returns over 1000 rows of data > 2 - Run the report > 3 - Note you have two buttons now 'Chart data' and 'Fetch all data for chart' > 4 - Click chart data > 5 - Note the note that you are only charting visible data > 6 - Create the chart and confirm it works > 7 - Close the chart > 8 - Click 'Fetch all data' > 9 - Note the confirm window >10 - Click 'cancel', note there is no change >11 - Repeat and click ok >12 - Fetch all data button is gone >13 - Page to next data, note fetch all does not return >14 - Click 'Chart data' >15 - Note you now have checkbox option to use all data in report >16 - Click it >17 - Create chart >18 - Confirm it works as expected > >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> >Signed-off-by: Séverine QUEUNE <severine.queune@bulac.fr> >--- > koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc | 14 +++++++---- > .../prog/en/includes/reports-toolbar.inc | 8 ++++++- > .../en/modules/reports/guided_reports_start.tt | 27 +++++++++++++++++----- > reports/guided_reports.pl | 13 +++++++---- > 4 files changed, 46 insertions(+), 16 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc >index cb1f6d3..eaec0db 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc >@@ -33,10 +33,16 @@ > </select> > </li> > >- <li> >- <label for="include-all">Include all rows (ignore pagination):</label> >- <input id="include-all" name="chart-include-all" type="checkbox" /> >- </li> >+ [% IF allresults.size %] >+ <li> >+ <label for="include-all">Include all rows (ignore pagination):</label> >+ <input id="include-all" name="chart-include-all" type="checkbox" /> >+ </li> >+ [% ELSE %] >+ <li> >+ <p>This chart will use only visible rows, click 'Fetch all data' to chart the full report</p> >+ </li> >+ [% END %] > > <li> > <label for="exclude-last">Exclude last line (Rollup): </label> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc >index cd787ca..8fd8c4d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/reports-toolbar.inc >@@ -107,7 +107,13 @@ > <a class="btn btn-default toggle_sql" id="toggle_sql_vis" href="#" style="display:none;"><i class="fa fa-eye-slash"></i> Hide SQL code</a> > </div> > <div class="btn-group"> >- <a class="btn btn-default" href="#" data-toggle="modal" data-target="#chartModal"><i class="fa fa-bar-chart"></i> Create chart</a> >+ [% IF allresults.size %] >+ <a class="btn btn-default" href="#" data-toggle="modal" data-target="#chartModal"><i class="fa fa-bar-chart"></i> Create chart</a> >+ [% ELSE %] >+ <a class="btn btn-default" href="#" data-toggle="modal" data-target="#chartModal"><i class="fa fa-bar-chart"></i> Create chart</a> >+ <a class="btn btn-default fetch_chart_data" href="/cgi-bin/koha/reports/guided_reports.pl?reports=[% id | html %]&phase=Run this report&reportname=[% name |uri %][% PROCESS params %]&want_full_chart=1"><i class="fa fa-bar-chart"></i> Fetch all data for chart</a> >+ [% END %] >+ > </div> > [% END %] > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >index de04098..821ab6f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt >@@ -1158,6 +1158,17 @@ canned reports and writing custom SQL reports.</p> > } > > $(document).ready(function(){ >+ >+ $("body").on('click',".fetch_chart_data",function(){ >+ if( [% unlimited_total %] > 1000 ){ >+ if( confirm("Fetching full chart data for reports with many rows can cause performance issues. Are you sure you with to chart this report?") ){ >+ return true; >+ } else { >+ return false; >+ } >+ } >+ }); >+ > var showsql; > hide_bar_element(); > >@@ -1200,12 +1211,16 @@ canned reports and writing custom SQL reports.</p> > headers = [% header_row.json | $raw %]; > > var results; >- if ($('input[name="chart-include-all"]').prop('checked')) { >- results = [% allresults.json | $raw %] >- } >- else { >- results = [% results.json | $raw %] >- } >+ [% IF allresults.size %] >+ if ($('input[name="chart-include-all"]').prop('checked')) { >+ results = [% allresults.json | $raw %] >+ } >+ else { >+ results = [% results.json | $raw %] >+ } >+ [% ELSE %] >+ results = [% results.json | $raw %]; >+ [% END %] > > if ($('input[name="chart-exclude-last"]').prop('checked')) { > results.splice(-1, 1); >diff --git a/reports/guided_reports.pl b/reports/guided_reports.pl >index bb4e87e..7061554 100755 >--- a/reports/guided_reports.pl >+++ b/reports/guided_reports.pl >@@ -692,6 +692,7 @@ elsif ($phase eq 'Run this report'){ > my $report_id = $input->param('reports'); > my @sql_params = $input->multi_param('sql_params'); > my @param_names = $input->multi_param('param_name'); >+ my $want_full_chart = $input->param('want_full_chart') || 0; > > # offset algorithm > if ($input->param('page')) { >@@ -828,7 +829,6 @@ elsif ($phase eq 'Run this report'){ > my ($sql,$header_types) = get_prepped_report( $sql, \@param_names, \@sql_params); > $template->param(header_types => $header_types); > my ( $sth, $errors ) = execute_query( $sql, $offset, $limit, undef, $report_id ); >- my ($sth2, $errors2) = execute_query($sql); > my $total = nb_rows($sql) || 0; > unless ($sth) { > die "execute_query failed to return sth for report $report_id: $sql"; >@@ -839,14 +839,17 @@ elsif ($phase eq 'Run this report'){ > my @cells = map { +{ cell => $_ } } @$row; > push @rows, { cells => \@cells }; > } >- while (my $row = $sth2->fetchrow_arrayref()) { >- my @cells = map { +{ cell => $_ } } @$row; >- push @allrows, { cells => \@cells }; >+ if( $want_full_chart ){ >+ my ($sth2, $errors2) = execute_query($sql); >+ while (my $row = $sth2->fetchrow_arrayref()) { >+ my @cells = map { +{ cell => $_ } } @$row; >+ push @allrows, { cells => \@cells }; >+ } > } > } > > my $totpages = int($total/$limit) + (($total % $limit) > 0 ? 1 : 0); >- my $url = "/cgi-bin/koha/reports/guided_reports.pl?reports=$report_id&phase=Run%20this%20report&limit=$limit"; >+ my $url = "/cgi-bin/koha/reports/guided_reports.pl?reports=$report_id&phase=Run%20this%20report&limit=$limit&want_full_chart=$want_full_chart"; > if (@param_names) { > $url = join('&param_name=', $url, map { URI::Escape::uri_escape_utf8($_) } @param_names); > } >-- >2.7.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 23626
:
92845
|
92904
|
92905
|
92908
|
92909
|
92910
|
92919
|
92920
|
92921
|
92992
|
92994
|
93126
|
93137
|
93204
|
93406
|
93589
|
93720
|
93723
|
93729
|
93914
|
93915
|
93916
|
93981