Skip to content

Commit

Permalink
Merge pull request #179 from AlexanderBlanchardAC/DIS-314-Remove-Resu…
Browse files Browse the repository at this point in the history
…lts-From-Summon-Search

Dis 314 remove results from summon search
  • Loading branch information
AlexanderBlanchardAC authored Feb 10, 2025
2 parents 5e2c890 + 2faac59 commit d8a3db3
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
2 changes: 2 additions & 0 deletions code/web/release_notes/25.03.00.MD
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
// james

// alexander
## Summon Updates
- 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/24.02.00.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,13 @@ function getUpdates24_02_00(): array {
) ENGINE INNODB",
],
],
'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",
],
],
//indexed_information_places_of_publication
'add_place_of_publication_to_grouped_work' => [
'title' => 'Add Place of Publication to Grouped Work',
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,
],
];
}
}

0 comments on commit d8a3db3

Please sign in to comment.