Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dis 314 remove results from summon search #187

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions code/web/release_notes/25.03.00.MD
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
// alexander
### Summon Updates
- Update the Summon Search Indexes to match those found in Summon Serials Solutions. (DIS-232) (*AB*)
- Add a setting in Summon Settings that gives the option of filtering out results from the library catalog when searching using Summon. (DIS-314) (*AB*)

// chloe

Expand Down
7 changes: 7 additions & 0 deletions code/web/sys/DBMaintenance/version_updates/25.03.00.php
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,13 @@ function getUpdates25_03_00(): array {
// Leo Stoyanov - BWS

//alexander - PTFS-Europe
'filter_books_from_summon_results' => [
'title' => 'Filter Books From Summon Results',
'description' => 'Add the option of filtering out records with the content type of book or ebook from Summon results',
'sql' => [
"ALTER TABLE summon_settings ADD COLUMN filterOutBooksAndEbooks TINYINT(1) NOT NULL DEFAULT 0",
],
],

//chloe - PTFS-Europe

Expand Down
19 changes: 19 additions & 0 deletions code/web/sys/SearchObject/SummonSearcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,19 @@ public function processData($recordData, $textQuery = null) {
$splitFacets = $this->splitFacets($recordData['facetFields']);
$this->facetFields = $splitFacets['facetFields'];
$this->limitFields = $splitFacets['limitFields'];

$summonSettings = $this->getSettings();
if ($summonSettings && !empty($summonSettings->filterOutBooksAndEbooks)) {
foreach ($this->facetFields as $key => $facet) {
if ($facet['displayName'] === 'ContentType') {
foreach ($facet['counts'] as $index => $count) {
if (isset($count['value']) && ($count['value'] === 'Book / eBook' || $count['value'] === 'Book%20%2F%20eBook')) {
unset($this->facetFields[$key]['counts'][$index]);
}
}
}
}
}
}
return $recordData;
}
Expand Down Expand Up @@ -572,6 +585,12 @@ public function getSummonFilters() {
$this->filters[] = urlencode($key) . ',' . $encodedValue . ',';
}
}

$summonSettings = $this->getSettings();

if ($summonSettings && !empty($summonSettings->filterOutBooksAndEbooks)) {
$this->filters[] = 'ContentType,Book%20%2F%20eBook,t';
}
return $this->filters;
}

Expand Down
9 changes: 9 additions & 0 deletions code/web/sys/Summon/SummonSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class SummonSettings extends DataObject {
public $summonApiId;
public $summonApiPassword;
public $summonBaseApi;
public $filterOutBooksAndEbooks;

function getEncryptedFieldNames(): array {
return ['summonApiPassword'];
Expand Down Expand Up @@ -50,6 +51,14 @@ public static function getObjectStructure($context = ''): array {
'description' => 'The password to use when connecting to the Summon API',
'hideInLists' => true,
],
'filterOutBooksAndEbooks' => [
'property' => 'filterOutBooksAndEbooks',
'type' => 'checkbox',
'default' => false,
'label' => 'Filter Out Books And eBooks',
'description' => 'Whether or not to include books and ebooks in the summon search results',
'hideInLists' => true,
],
];
}
}