Bug 7249: Syspref to control number of rows in web service results
authorJared Camins-Esakov <jcamins@cpbibliography.com>
Sun, 29 Apr 2012 19:41:30 +0000 (15:41 -0400)
committerPaul Poulain <paul.poulain@biblibre.com>
Fri, 11 May 2012 08:26:33 +0000 (10:26 +0200)
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.

Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
installer/data/mysql/sysprefs.sql
installer/data/mysql/updatedatabase.pl
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/web_services.pref
opac/svc/report
svc/report

index 49debd2..1edf08e 100644 (file)
@@ -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');
index 72e7eb2..9d0171b 100755 (executable)
@@ -5232,6 +5232,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)
index fae1fa9..7244675 100644 (file)
@@ -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.
index e60e924..4fd8183 100755 (executable)
@@ -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);
index dd8f8dc..476475c 100755 (executable)
@@ -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);