Bugzilla – Attachment 24913 Details for
Bug 11491
Extending report service to be annotated
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 11491 - Missing field names in JSON data
Bug-11491---Missing-field-names-in-JSON-data.patch (text/plain), 6.70 KB, created by
Mark Tompsett
on 2014-01-31 03:51:42 UTC
(
hide
)
Description:
Bug 11491 - Missing field names in JSON data
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2014-01-31 03:51:42 UTC
Size:
6.70 KB
patch
obsolete
>From 90b9179e1076c87266dd342a9eba4a801acc9269 Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Tue, 7 Jan 2014 14:39:46 -0500 >Subject: [PATCH] Bug 11491 - Missing field names in JSON data > >Added a parameter (annotated), which when non-empty will generate >an array of hashes that include the field names as keys, not >the typical array of field values, for the JSON output. > >Added functionality to staff svc/report as well. > >Moved code around to make diffs between svc/report and >opac/svc/report smaller. > >TEST PLAN >--------- > 1) Log into staff client > 2) Reports > 3) Used save reports > 4) Click the Action button on any report > WITHOUT PARAMETERS. > -- with parameters blows up in master and this. > 5) Click Edit > 6) Make the report public > 7) Update the SQL > 8) Note the ID number of the report > 9) Note the ID number of a non-public report >10) Make up a crazy ID number for a non-existant report >11) In a new tab (with the appropriate edits) > https://OPAC/cgi-bin/koha/svc/report?id=# from step 8 > -- JSON data has arrays of field values. > https://OPAC/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 > -- JSON data has arrays of field values. > https://OPAC/cgi-bin/koha/svc/report?id=# from step 9 > -- Software error: Sorry this report is not public > https://OPAC/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 > -- Software error: Sorry this report is not public > https://OPAC/cgi-bin/koha/svc/report?id=# from step 10 > -- Software error: Sorry this report is not public > https://OPAC/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 > -- Software error: Sorry this report is not public > https://STAFF/cgi-bin/koha/svc/report?id=# from step 8 > -- JSON data has arrays of field values. > https://STAFF/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 > -- JSON data has arrays of field values. > https://STAFF/cgi-bin/koha/svc/report?id=# from step 9 > -- JSON data has arrays of field values. > https://STAFF/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 > -- JSON data has arrays of field values. > https://STAFF/cgi-bin/koha/svc/report?id=# from step 10 > -- Software error: hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at /usr/share/perl5/JSON.pm line 154. > https://STAFF/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 > -- Software error: hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at /usr/share/perl5/JSON.pm line 154. > >12) Apply the patch >13) ~/qa-test-tools/koha-qa.pl -v 2 -c 2 > -- There should be no problems. All OK. > >14) In a new tab (with the appropriate edits) > https://OPAC/cgi-bin/koha/svc/report?id=# from step 8 > -- JSON data has arrays of field values. > https://OPAC/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 > -- JSON data has arrays of field values. > https://OPAC/cgi-bin/koha/svc/report?id=# from step 9 > -- Software error: Sorry this report is not public > https://OPAC/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 > -- Software error: Sorry this report is not public > https://OPAC/cgi-bin/koha/svc/report?id=# from step 10 > -- Software error: Sorry this report is not public > https://OPAC/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 > -- Software error: Sorry this report is not public > https://STAFF/cgi-bin/koha/svc/report?id=# from step 8 > -- JSON data has arrays of field values. > https://STAFF/cgi-bin/koha/svc/report?id=# from step 8&annotated=1 > -- JSON data has arrays of field values. > https://STAFF/cgi-bin/koha/svc/report?id=# from step 9 > -- JSON data has arrays of field values. > https://STAFF/cgi-bin/koha/svc/report?id=# from step 9&annotated=1 > -- JSON data has arrays of field values. > https://STAFF/cgi-bin/koha/svc/report?id=# from step 10 > -- Software error: hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at /usr/share/perl5/JSON.pm line 154. > https://STAFF/cgi-bin/koha/svc/report?id=# from step 10&annotated=1 > -- Software error: hash- or arrayref expected (not a simple scalar, use allow_nonref to allow this) at /usr/share/perl5/JSON.pm line 154. >--- > opac/svc/report | 12 ++++++++++-- > svc/report | 13 +++++++++++-- > 2 files changed, 21 insertions(+), 4 deletions(-) > >diff --git a/opac/svc/report b/opac/svc/report >index 38cbd42..f6cd6b9 100755 >--- a/opac/svc/report >+++ b/opac/svc/report >@@ -30,10 +30,12 @@ use Koha::Cache; > my $query = CGI->new(); > my $report_id = $query->param('id'); > my $report_name = $query->param('name'); >+my $report_annotation = $query->param('annotated'); > > my $report_rec = get_saved_report( $report_name ? { 'name' => $report_name } : { 'id' => $report_id } ); >-die "Sorry this report is not public\n" unless $report_rec->{public}; >+if (!$report_rec) { die "There is no such report.\n"; } > >+die "Sorry this report is not public\n" unless $report_rec->{public}; > > my $cache_active = Koha::Cache->is_cache_active; > my ($cache_key, $cache, $json_text); >@@ -48,7 +50,13 @@ unless ($json_text) { > my $limit = C4::Context->preference("SvcMaxReportRows") || 10; > my ( $sth, $errors ) = execute_query( $report_rec->{savedsql}, $offset, $limit ); > if ($sth) { >- my $lines = $sth->fetchall_arrayref; >+ my $lines; >+ if ($report_annotation) { >+ $lines = $sth->fetchall_arrayref({}); >+ } >+ else { >+ $lines = $sth->fetchall_arrayref; >+ } > $json_text = to_json($lines); > > if ($cache_active) { >diff --git a/svc/report b/svc/report >index 654ef15..41ea125 100755 >--- a/svc/report >+++ b/svc/report >@@ -32,6 +32,10 @@ use Koha::Cache; > my $query = CGI->new(); > my $report_id = $query->param('id'); > my $report_name = $query->param('name'); >+my $report_annotation = $query->param('annotated'); >+ >+my $report_rec = get_saved_report( $report_name ? { 'name' => $report_name } : { 'id' => $report_id } ); >+if (!$report_rec) { die "There is no such report.\n"; } > > my ( $template, $loggedinuser, $cookie ) = get_template_and_user( > { >@@ -52,12 +56,17 @@ if ($cache_active) { > } > > unless ($json_text) { >- my $report_rec = get_saved_report($report_name ? { 'name' => $report_name } : { 'id' => $report_id }); > my $offset = 0; > my $limit = C4::Context->preference("SvcMaxReportRows") || 10; > my ( $sth, $errors ) = execute_query( $report_rec->{savedsql}, $offset, $limit ); > if ($sth) { >- my $lines = $sth->fetchall_arrayref; >+ my $lines; >+ if ($report_annotation) { >+ $lines = $sth->fetchall_arrayref({}); >+ } >+ else { >+ $lines = $sth->fetchall_arrayref; >+ } > $json_text = to_json($lines); > > if ($cache_active) { >-- >1.7.9.5
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 11491
:
24000
|
24001
|
24002
|
24909
|
24910
|
24911
|
24912
|
24913
|
24914
|
24915
|
24916
|
24917
|
24923
|
24924
|
24960
|
24961