From ee31ea7487e6d869ccc6989ad68a4e2425b24521 Mon Sep 17 00:00:00 2001 From: Gilles Crettenand Date: Thu, 18 Jun 2015 15:05:36 +0200 Subject: [PATCH] speed up MoreLikeLoans by avoiding hitting solr --- Lib/db/User.php | 11 ++++++++--- NetBiblio.php | 8 ++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Lib/db/User.php b/Lib/db/User.php index 50ff8e5..f2bdfc1 100644 --- a/Lib/db/User.php +++ b/Lib/db/User.php @@ -122,8 +122,10 @@ class User extends DbMapping return $result ? $result->to_array() : array(); } - private function _getLoans($table, $sort = "ItemNr ASC") { + public function getLoansData($table, $sort = "ItemNr ASC") + { $sql = sprintf("SELECT + n.NoticeId, n.NoticeNr, CheckOutDate, ItemNr @@ -134,9 +136,12 @@ class User extends DbMapping c.UserAccountID = %s ORDER BY %s", $table, $this->id, $sort); - $result = Connection::execute($sql); + return Connection::execute($sql)->to_array(); + } - $circulations = $result->to_array(); + private function _getLoans($table, $sort = "ItemNr ASC") + { + $circulations = $this->getLoansData($table, $sort); // getting the intval of the NoticeNr will remove any 'V' or 'T' and thus we will have no issues with // the virtual books that are used for Downloads and so. $codes = array_unique(array_map(function($c) { return intval(trim($c['NoticeNr'])); }, $circulations)); diff --git a/NetBiblio.php b/NetBiblio.php index 1added2..711c3ae 100644 --- a/NetBiblio.php +++ b/NetBiblio.php @@ -735,12 +735,8 @@ class NetBiblio extends WebService */ public function MoreLikeLoans() { - $_SESSION["user"]["login"] = 35; - - $loans = $this->getUser()->GetOldLoans(); - $ids = array_map(function($l) { - return $l['id']; - }, $loans); + $circulations = $this->getUser()->getLoansData('OldCirculations'); + $ids = array_map(function($c) { return $c['NoticeId']; }, $circulations); return $this->MoreLikeThis($ids); }