From 057cc9ea3acddf30b01b6f4036e094c31fb0091a Mon Sep 17 00:00:00 2001 From: Jared Camins-Esakov Date: Sun, 29 Apr 2012 15:41:30 -0400 Subject: [PATCH] Bug 7249: Syspref to control number of rows in web service results Content-Type: text/plain; charset="UTF-8" The original patches for bug 7249 had a hardcoded limit of ten rows in the results returned by the web service. This patch adds a SvcMaxReportRows syspref which allows the librarian to choose how many rows should be returned by the web service. --- installer/data/mysql/sysprefs.sql | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++++ .../en/modules/admin/preferences/web_services.pref | 8 +++++++- opac/svc/report | 2 +- svc/report | 4 ++-- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 49debd2..1edf08e 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -362,3 +362,4 @@ INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES(' INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('AutoResumeSuspendedHolds', '1', NULL , 'Allow suspended holds to be automatically resumed by a set date.', 'YesNo'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES ('OpacStarRatings','all',NULL,'disable|all|details','Choice'); INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('OpacBrowseResults','1','Disable/enable browsing and paging search results from the OPAC detail page.',NULL,'YesNo'); +INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SvcMaxReportRows','10','Maximum number of rows to return via the report web service.',NULL,'Integer'); diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 063e91b..902d48a 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -5225,6 +5225,13 @@ saved_reports table.)\n"; SetVersion($DBversion); } +$DBversion = "3.09.00.XXX"; +if ( C4::Context->preference("Version") < TransformToNum($DBversion) ) { + $dbh->do("INSERT INTO systempreferences (variable,value,explanation,options,type) VALUES('SvcMaxReportRows','10','Maximum number of rows to return via the report web service.',NULL,'Integer');"); + print "Upgrade to $DBversion done (Added SvcMaxReportRows syspref)\n"; + SetVersion($DBversion); +} + =head1 FUNCTIONS =head2 TableExists($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref index fae1fa9..7244675 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref @@ -1,4 +1,4 @@ -Web Services: +Web services: OAI-PMH: - - pref: OAI-PMH @@ -38,3 +38,9 @@ Web Services: - pref: ILS-DI:AuthorizedIPs class: Text - allowed IPs to use the ILS-DI services + Reporting: + - + - Only return + - pref: SvcMaxReportRows + class: integer + - rows of a report requested via the reports web service. diff --git a/opac/svc/report b/opac/svc/report index e60e924..4fd8183 100755 --- a/opac/svc/report +++ b/opac/svc/report @@ -55,7 +55,7 @@ if ($usecache) { print $query->header; my $offset = 0; -my $limit = 10; +my $limit = C4::Context->preference("SvcMaxReportRows") || 10; my ( $sth, $errors ) = execute_query( $sql, $offset, $limit ); my $lines = $sth->fetchall_arrayref; my $json_text = to_json($lines); diff --git a/svc/report b/svc/report index dd8f8dc..476475c 100755 --- a/svc/report +++ b/svc/report @@ -30,7 +30,7 @@ my $query = CGI->new(); my $report = $query->param('id'); my $cache; -my $usecache = C4::Context->preference('usecache'); +my $usecache = C4::Context->ismemcached; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -66,7 +66,7 @@ print $query->header; my ( $sql, $type, $name, $notes, $cache_expiry, $public ) = get_saved_report($report); my $offset = 0; -my $limit = 10; +my $limit = C4::Context->preference("SvcMaxReportRows") || 10; my ( $sth, $errors ) = execute_query( $sql, $offset, $limit ); my $lines = $sth->fetchall_arrayref; my $json_text = to_json($lines); -- 1.7.2.5