Skip to content

Commit

Permalink
[FINNA-1898] Fix holdings summary array contents.
Browse files Browse the repository at this point in the history
  • Loading branch information
EreMaijala committed Feb 15, 2024
1 parent 5125823 commit a0a2ef3
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 62 deletions.
9 changes: 6 additions & 3 deletions module/Finna/src/Finna/ILS/Driver/Alma.php
Original file line number Diff line number Diff line change
Expand Up @@ -2031,10 +2031,11 @@ public function getHolding($id, $patron = null, array $options = [])
$this->config['Holdings']['externalInterfaceUrl'] ?? ''
);
$summary = [
'id' => $id,
'available' => $items['available'],
'total' => $items['total'],
'availability' => null,
'callnumber' => null,
'callnumber' => '',
'location' => '__HOLDINGSSUMMARYLOCATION__',
'externalInterfaceUrl' => $externalInterfaceUrl,
];
Expand Down Expand Up @@ -2160,11 +2161,12 @@ public function getHolding($id, $patron = null, array $options = [])

// Add summary
$summary = [
'id' => $id,
'available' => $totalAvailable,
'total' => $total,
'locations' => count($locations),
'availability' => null,
'callnumber' => null,
'callnumber' => '',
'location' => '__HOLDINGSSUMMARYLOCATION__',
];
if ($displayRequests) {
Expand Down Expand Up @@ -2841,12 +2843,13 @@ protected function getStatusesForInventoryTypes($ids, $types)
// we need to add a few dummy-fields that VuFind expects to be
// defined for all elements.
$summary = [
'id' => (string)$bib->mms_id,
'available' => $itemsAvailable,
'total' => $itemsTotal,
'ordered' => $itemsOrdered,
'locations' => count(array_unique(array_column($status, 'location'))),
'availability' => null,
'callnumber' => null,
'callnumber' => '',
'location' => '__HOLDINGSSUMMARYLOCATION__',
'externalInterfaceUrl' => $externalInterfaceUrl,
];
Expand Down
30 changes: 16 additions & 14 deletions module/Finna/src/Finna/ILS/Driver/AxiellWebServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@ class AxiellWebServices extends \VuFind\ILS\Driver\AbstractBase implements
/**
* Institution settings for the order of organisations
*
* @var string
* @var array
*/
protected $holdingsOrganisationOrder;

/**
* Institution settings for the order of branches
*
* @var string
* @var array
*/
protected $holdingsBranchOrder;

Expand Down Expand Up @@ -1108,7 +1108,7 @@ public function getHolding($id, array $patron = null, array $options = [])
if (!empty($result)) {
usort($result, [$this, 'holdingsSortFunction']);

$summary = $this->getHoldingsSummary($result);
$summary = $this->getHoldingsSummary($result, $id);
$result[] = $summary;
}

Expand Down Expand Up @@ -1273,11 +1273,12 @@ protected function parseHoldings($organisationHoldings, $id, $journalInfo = null
/**
* Return summary of holdings items.
*
* @param array $holdings Parsed holdings items
* @param array $holdings Parsed holdings items
* @param string $id Record id
*
* @return array summary
*/
protected function getHoldingsSummary($holdings)
protected function getHoldingsSummary($holdings, $id)
{
$holdable = false;
$journal = isset($holdings[0]['journalInfo']);
Expand Down Expand Up @@ -1315,15 +1316,16 @@ protected function getHoldingsSummary($holdings)
// we need to add a few dummy-fields that VuFind expects to be
// defined for all elements.
return [
'available' => $availableTotal,
'ordered' => $orderedTotal,
'total' => $itemsTotal - $orderedTotal,
'reservations' => $reservationsTotal,
'locations' => count($locations),
'holdable' => $holdable,
'availability' => null,
'callnumber' => '',
'location' => '__HOLDINGSSUMMARYLOCATION__',
'id' => $id,
'available' => $availableTotal,
'ordered' => $orderedTotal,
'total' => $itemsTotal - $orderedTotal,
'reservations' => $reservationsTotal,
'locations' => count($locations),
'holdable' => $holdable,
'availability' => null,
'callnumber' => '',
'location' => '__HOLDINGSSUMMARYLOCATION__',
];
}

Expand Down
26 changes: 14 additions & 12 deletions module/Finna/src/Finna/ILS/Driver/Demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public function getStatus($id)
{
$result = parent::getStatus($id);
if (!empty($result)) {
$result[] = $this->getHoldingsSummary($result);
$result[] = $this->getHoldingsSummary($result, $id);
}
return $result;
}
Expand All @@ -132,7 +132,7 @@ public function getHolding($id, array $patron = null, array $options = [])
{
$result = parent::getHolding($id, $patron, $options);
if (!empty($result['holdings'])) {
$result['holdings'][] = $this->getHoldingsSummary($result['holdings']);
$result['holdings'][] = $this->getHoldingsSummary($result['holdings'], $id);
}
return $result;
}
Expand Down Expand Up @@ -484,11 +484,12 @@ protected function pickUpLocationIsValid($pickUpLocation, $patron, $holdDetails)
/**
* Return summary of holdings items.
*
* @param array $holdings Parsed holdings items
* @param array $holdings Parsed holdings items
* @param string $id Record id
*
* @return array summary
*/
protected function getHoldingsSummary($holdings)
protected function getHoldingsSummary($holdings, $id)
{
$availableTotal = $itemsTotal = 0;
$requests = 0;
Expand All @@ -512,14 +513,15 @@ protected function getHoldingsSummary($holdings)
// Use a stupid location name to make sure this doesn't get mixed with
// real items that don't have a proper location.
$result = [
'available' => $availableTotal,
'total' => $itemsTotal,
'locations' => count($locations),
'availability' => null,
'callnumber' => null,
'location' => '__HOLDINGSSUMMARYLOCATION__',
'reservations' => rand(0, 8),
'ordered' => rand(0, 20),
'id' => $id,
'available' => $availableTotal,
'total' => $itemsTotal,
'locations' => count($locations),
'availability' => null,
'callnumber' => '',
'location' => '__HOLDINGSSUMMARYLOCATION__',
'reservations' => rand(0, 8),
'ordered' => rand(0, 20),
];
return $result;
}
Expand Down
15 changes: 8 additions & 7 deletions module/Finna/src/Finna/ILS/Driver/KohaRest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1333,13 +1333,14 @@ protected function getItemStatusesForBiblio($id, $patron = null, $brief = false)

// Add summary
$summary = [
'available' => $availableTotal,
'total' => $itemsTotal,
'ordered' => $orderedTotal,
'locations' => count(array_unique(array_column($statuses, 'location'))),
'availability' => null,
'callnumber' => null,
'location' => '__HOLDINGSSUMMARYLOCATION__',
'id' => $id,
'available' => $availableTotal,
'total' => $itemsTotal,
'ordered' => $orderedTotal,
'locations' => count(array_unique(array_column($statuses, 'location'))),
'availability' => null,
'callnumber' => '',
'location' => '__HOLDINGSSUMMARYLOCATION__',
];
if (!empty($this->config['Holdings']['display_total_hold_count'])) {
$summary['reservations'] = $requestsTotal;
Expand Down
24 changes: 13 additions & 11 deletions module/Finna/src/Finna/ILS/Driver/KohaRestSuomi.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public function getHolding($id, array $patron = null, array $options = [])
{
$data = parent::getHolding($id, $patron);
if (!empty($data['holdings'])) {
$summary = $this->getHoldingsSummary($data['holdings']);
$summary = $this->getHoldingsSummary($data['holdings'], $id);

// Remove request counts before adding the summary if necessary
if (
Expand Down Expand Up @@ -185,7 +185,7 @@ public function getStatus($id)
{
$data = parent::getStatus($id);
if (!empty($data)) {
$summary = $this->getHoldingsSummary($data);
$summary = $this->getHoldingsSummary($data, $id);
$data[] = $summary;
}
return $data;
Expand Down Expand Up @@ -1078,13 +1078,14 @@ public function getPickUpLocations($patron = false, $holdDetails = null)
/**
* Return summary of holdings items.
*
* @param array $holdings Parsed holdings items
* @param array $holdings Parsed holdings items
* @param string $id Record id
*
* @return array summary
*/
protected function getHoldingsSummary($holdings)
protected function getHoldingsSummary($holdings, $id)
{
$availableTotal = $itemsTotal = $reservationsTotal = 0;
$availableTotal = $itemsTotal = 0;
$requests = 0;
$locations = [];

Expand All @@ -1108,12 +1109,13 @@ protected function getHoldingsSummary($holdings)
// Use a stupid location name to make sure this doesn't get mixed with
// real items that don't have a proper location.
$result = [
'available' => $availableTotal,
'total' => $itemsTotal,
'locations' => count($locations),
'availability' => null,
'callnumber' => null,
'location' => '__HOLDINGSSUMMARYLOCATION__',
'id' => $id,
'available' => $availableTotal,
'total' => $itemsTotal,
'locations' => count($locations),
'availability' => null,
'callnumber' => '',
'location' => '__HOLDINGSSUMMARYLOCATION__',
];
if (!empty($this->config['Holdings']['display_total_hold_count'])) {
$result['reservations'] = $requests;
Expand Down
30 changes: 16 additions & 14 deletions module/Finna/src/Finna/ILS/Driver/Mikromarc.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ public function getHolding($id, array $patron = null, array $options = [])
{
$data = $this->getItemStatusesForBiblio($id, $patron);
if (!empty($data)) {
$summary = $this->getHoldingsSummary($data);
$summary = $this->getHoldingsSummary($data, $id);
$data[] = $summary;
}
return $data;
Expand Down Expand Up @@ -1769,11 +1769,12 @@ protected function getItemStatusesForBiblio($id, $patron = null)
/**
* Return summary of holdings items.
*
* @param array $holdings Parsed holdings items
* @param array $holdings Parsed holdings items
* @param string $id Record id
*
* @return array summary
*/
protected function getHoldingsSummary($holdings)
protected function getHoldingsSummary($holdings, $id)
{
$holdable = false;
$titleHold = true;
Expand Down Expand Up @@ -1803,17 +1804,18 @@ protected function getHoldingsSummary($holdings)
// we need to add a few dummy-fields that VuFind expects to be
// defined for all elements.
return [
'available' => $availableTotal,
'ordered' => $orderedTotal,
'total' => $itemsTotal,
'reservations' => $reservationsTotal,
'locations' => count($locations),
'holdable' => $holdable,
'availability' => null,
'callnumber' => null,
'location' => '__HOLDINGSSUMMARYLOCATION__',
'groupBranches' => false,
'titleHold' => $titleHold,
'id' => $id,
'available' => $availableTotal,
'ordered' => $orderedTotal,
'total' => $itemsTotal,
'reservations' => $reservationsTotal,
'locations' => count($locations),
'holdable' => $holdable,
'availability' => null,
'callnumber' => '',
'location' => '__HOLDINGSSUMMARYLOCATION__',
'groupBranches' => false,
'titleHold' => $titleHold,
];
}

Expand Down
3 changes: 2 additions & 1 deletion module/Finna/src/Finna/ILS/Driver/SierraRest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1255,12 +1255,13 @@ protected function getItemStatusesForBib(string $id, bool $checkHoldings, ?array
// we need to add a few dummy-fields that VuFind expects to be
// defined for all elements.
$summary = [
'id' => $id,
'available' => $itemsAvailable,
'total' => $itemsTotal,
'ordered' => $itemsOrdered,
'locations' => count(array_unique(array_column($statuses, 'location'))),
'availability' => null,
'callnumber' => null,
'callnumber' => '',
'location' => '__HOLDINGSSUMMARYLOCATION__',
];
if ($this->config['Holdings']['display_total_hold_count'] ?? true) {
Expand Down

0 comments on commit a0a2ef3

Please sign in to comment.