Skip to content

Commit 55a6af0

Browse files
Merge pull request #187 from AlexanderBlanchardAC/DIS-314-Remove-Results-From-Summon-Search
Dis 314 remove results from summon search
2 parents 4a75246 + 9101691 commit 55a6af0

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

code/web/release_notes/25.03.00.MD

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
// alexander
6565
### Summon Updates
6666
- Update the Summon Search Indexes to match those found in Summon Serials Solutions. (DIS-232) (*AB*)
67+
- 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*)
6768

6869
// chloe
6970

code/web/sys/DBMaintenance/version_updates/25.03.00.php

+7
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,13 @@ function getUpdates25_03_00(): array {
167167
// Leo Stoyanov - BWS
168168

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

171178
//chloe - PTFS-Europe
172179

code/web/sys/SearchObject/SummonSearcher.php

+19
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,19 @@ public function processData($recordData, $textQuery = null) {
291291
$splitFacets = $this->splitFacets($recordData['facetFields']);
292292
$this->facetFields = $splitFacets['facetFields'];
293293
$this->limitFields = $splitFacets['limitFields'];
294+
295+
$summonSettings = $this->getSettings();
296+
if ($summonSettings && !empty($summonSettings->filterOutBooksAndEbooks)) {
297+
foreach ($this->facetFields as $key => $facet) {
298+
if ($facet['displayName'] === 'ContentType') {
299+
foreach ($facet['counts'] as $index => $count) {
300+
if (isset($count['value']) && ($count['value'] === 'Book / eBook' || $count['value'] === 'Book%20%2F%20eBook')) {
301+
unset($this->facetFields[$key]['counts'][$index]);
302+
}
303+
}
304+
}
305+
}
306+
}
294307
}
295308
return $recordData;
296309
}
@@ -572,6 +585,12 @@ public function getSummonFilters() {
572585
$this->filters[] = urlencode($key) . ',' . $encodedValue . ',';
573586
}
574587
}
588+
589+
$summonSettings = $this->getSettings();
590+
591+
if ($summonSettings && !empty($summonSettings->filterOutBooksAndEbooks)) {
592+
$this->filters[] = 'ContentType,Book%20%2F%20eBook,t';
593+
}
575594
return $this->filters;
576595
}
577596

code/web/sys/Summon/SummonSettings.php

+9
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ class SummonSettings extends DataObject {
88
public $summonApiId;
99
public $summonApiPassword;
1010
public $summonBaseApi;
11+
public $filterOutBooksAndEbooks;
1112

1213
function getEncryptedFieldNames(): array {
1314
return ['summonApiPassword'];
@@ -50,6 +51,14 @@ public static function getObjectStructure($context = ''): array {
5051
'description' => 'The password to use when connecting to the Summon API',
5152
'hideInLists' => true,
5253
],
54+
'filterOutBooksAndEbooks' => [
55+
'property' => 'filterOutBooksAndEbooks',
56+
'type' => 'checkbox',
57+
'default' => false,
58+
'label' => 'Filter Out Books And eBooks',
59+
'description' => 'Whether or not to include books and ebooks in the summon search results',
60+
'hideInLists' => true,
61+
],
5362
];
5463
}
5564
}

0 commit comments

Comments
 (0)