Skip to content

Commit

Permalink
Use catalog_date instead of first_indexed when appropriate.
Browse files Browse the repository at this point in the history
  • Loading branch information
EreMaijala committed Feb 20, 2025
1 parent 9b60610 commit 66a88b0
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 5 deletions.
1 change: 1 addition & 0 deletions local/config/finna/Blender.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ hierarchicalFacetSortOptions[building] = top
hierarchicalFacetSeparators[format] = " > "
; Any fields listed below will be treated as new items facets
newItems[] = first_indexed
newItems[] = catalog_date
; Date visualisations
dateVis[] = main_date_str
dateRangeVis = search_daterange_mv:main_date_str
Expand Down
2 changes: 1 addition & 1 deletion local/config/finna/facets.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ topic_facet = Topic
;usage_rights_str_mv = "Usage Rights"
usage_rights_ext_str_mv = usage_rights_ext
hierarchy_parent_title = component_part_is_part_of
first_indexed = "New Items in Index"
catalog_date = "New Items in Index"
category_str_mv = category_facet_heading

; Facets that will appear at the top of search results when the TopFacets
Expand Down
11 changes: 11 additions & 0 deletions local/config/finna/searches.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,17 @@ last_indexed desc = sort_last_indexed
CallNumber = callnumber
WorkKeys = "main_date_str desc"

; This section allows you to specify hidden sorting options. They can be used to
; create a whitelist of sort values using regular expressions. If you want to do
; this add regexes to the pattern[] array. All sort values that match at least one
; of these pattern are allowed in searches.
; The first matching option is shown in the sort selection in the result list when
; none of the normal options in [Sorting] section is selected. The labels for the
; entries can be defined in pattern[] array keys or a separate label[] array.
[HiddenSorting]
pattern[sort_first_indexed_desc] = "^first_indexed desc$"
pattern[sort_first_indexed_desc] = "^catalog_date desc$"

; These settings control which fields are available to sort on in the collections
; module.
[CollectionModuleSort]
Expand Down
4 changes: 2 additions & 2 deletions local/config/vufind/facets-browse.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ relative_path = ../finna/facets.ini
override_full_sections = "CheckboxFacets,BrowseDatabase,BrowseJournal"

[Results_Settings]
collapsedFacets = author2Str,genre_facet,language,topic_facet,first_indexed
collapsedFacets = author2Str,genre_facet,language,topic_facet,first_indexed,catalog_date

[CheckboxFacets]

Expand All @@ -17,5 +17,5 @@ genre_facet = Genre
category_str_mv = category_facet_heading
language = Language
topic_facet = Topic
first_indexed = "New Items in Index"
catalog_date = "New Items in Index"

Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ public function getYear()
*/
public function getFirstIndexed()
{
return $this->fields['first_indexed'] ?? '';
return $this->fields['catalog_date'] ?? $this->fields['first_indexed'] ?? '';
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,24 @@ function ($s) {
!$this->validateSchedule($todayTime, $lastTime, $s)
|| !($user = $this->getUserForSearch($s))
|| !($searchObject = $this->getObjectForSearch($s))
|| !($newRecords = $this->getNewRecords($searchObject, $lastTime))
) {
continue;
}

// Use catalog_date if available as sort option:
$this->sort = 'first_indexed desc';
$sortOptions = $searchObject->getOptions()->getSortOptions();
foreach (array_keys($sortOptions) as $key) {
if (str_starts_with($key, 'catalog_date desc')) {
$this->sort = $key;
break;
}
}

if (!($newRecords = $this->getNewRecords($searchObject, $lastTime))) {
continue;
}

// Set email language
$this->setLanguage($user->getLastLanguage());

Expand Down

0 comments on commit 66a88b0

Please sign in to comment.