speed up MoreLikeLoans by avoiding hitting solr
This commit is contained in:
@@ -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));
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user