Bugzilla – Attachment 93126 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] Use svc/reports to fetch chart data
Bug-23626-alternate-Use-svcreports-to-fetch-chart-.patch (text/plain), 4.83 KB, created by
Nick Clemens (kidclamp)
on 2019-09-23 15:42:14 UTC
(
hide
)
Description:
Bug 23626: [alternate] Use svc/reports to fetch chart data
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2019-09-23 15:42:14 UTC
Size:
4.83 KB
patch
obsolete
>From 621bba15d18fb7e4753579a5a9455b6c2a876a9d Mon Sep 17 00:00:00 2001 >From: Nick Clemens <nick@bywatersolutions.com> >Date: Mon, 23 Sep 2019 15:26:39 +0000 >Subject: [PATCH] Bug 23626: [alternate] Use svc/reports to fetch chart data > >We have a method for getting json report data via svc, and this has a built in >limiter in the sysprefs. We can utilise this for our charts to avoid >passing all data in memory > >To test: >1 - Write a report that can be charted, for example: > SELECT RIGHT(barcode,2), COUNT(*) > FROM items > WHERE RIGHT(barcode,1) != <<Number>> > GROUP BY RIGHT(barcode,2) >2 - Set the 'Cache expiry' to 1 for this report >3 - Run it and click 'Create chart' on results page > Chart type: Pie > x column RIGHT(barcode,2) > Include all rows: UNCHECKED >4 - Note you get a nice pie chart >5 - Click 'Create chart', same except check 'Include all rows' >6 - Note you get a different pie >7 - Apply patch >8 - Repeat above - note that 'all rows' is now 'Fetch additional rows' and notes the sys pref control >9 - Increase SvcMaxReportRows and note chart changes >--- > koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc | 2 +- > .../en/modules/reports/guided_reports_start.tt | 32 ++++++++++++++++------ > 2 files changed, 24 insertions(+), 10 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc >index cb1f6d3b55..7c08bca28c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/chart.inc >@@ -34,7 +34,7 @@ > </li> > > <li> >- <label for="include-all">Include all rows (ignore pagination):</label> >+ <label for="include-all">Fetch additional rows ,up to preference SvcMaxReportRows ([% Koha.Preference('SvcMaxReportRows') %] ):</label> > <input id="include-all" name="chart-include-all" type="checkbox" /> > </li> > >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 de0409868a..d8f841c56d 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 >@@ -1190,7 +1190,29 @@ canned reports and writing custom SQL reports.</p> > > [% IF results && !errors %] > $('#draw-chart').click(function() { >+ var results = []; >+ if ($('input[name="chart-include-all"]').prop('checked')) { >+ $.getJSON("/cgi-bin/koha/svc/report?id=[% id %][%- FOREACH param IN sql_params %]&sql_params=[% param | uri %][% END %][%- FOREACH param_name IN param_names %]&param_name=[% param_name | uri %][% END %]",function(data){ >+ $.each(data, function(row_index,row_value){ >+ var row = []; >+ row_value.forEach(function(cell_value,cell_index){ >+ row.push({ cell: cell_value }); >+ }); >+ >+ results.push({ cells : row }); >+ }); >+ results.cells = results; >+ drawchart(results); >+ } >+ ); >+ } >+ else { >+ results = [% results.json | $raw %]; >+ drawchart(results); >+ } >+ }); > >+ function drawchart(results){ > var x_elements = $('select[name="x"]').val(); > var y_elements = []; > var groups = []; >@@ -1199,14 +1221,6 @@ 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 ($('input[name="chart-exclude-last"]').prop('checked')) { > results.splice(-1, 1); > } >@@ -1257,7 +1271,7 @@ canned reports and writing custom SQL reports.</p> > $("#download-chart,#toggle_chart_settings_hid,#chart").show(); > $("#toggle_chart_settings_vis").hide(); > $("#chartModal").modal("hide"); >- }); >+ }; > [% END %] > [% IF ( create ) %] > load_group_subgroups(); >-- >2.11.0
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