From d31238e73b6a28a2cbd6cd13879390a5b3ac4068 Mon Sep 17 00:00:00 2001 From: TheOtherP Date: Thu, 3 Oct 2024 11:35:10 +0200 Subject: [PATCH] Configure the number of recent searches shown in the search bar dropdown. --- .../src/main/java/org/nzbhydra/historystats/History.java | 5 ++++- core/src/main/resources/changelog.yaml | 6 ++++++ core/ui-src/js/config/config-fields-service.js | 9 +++++++++ .../main/java/org/nzbhydra/config/SearchingConfig.java | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/org/nzbhydra/historystats/History.java b/core/src/main/java/org/nzbhydra/historystats/History.java index 377386d91..04df2b148 100644 --- a/core/src/main/java/org/nzbhydra/historystats/History.java +++ b/core/src/main/java/org/nzbhydra/historystats/History.java @@ -7,6 +7,7 @@ import lombok.Data; import lombok.NoArgsConstructor; import org.hibernate.Hibernate; +import org.nzbhydra.config.ConfigProvider; import org.nzbhydra.downloading.FileDownloadEntity; import org.nzbhydra.historystats.stats.HistoryRequest; import org.nzbhydra.indexers.IndexerSearchEntity; @@ -48,6 +49,8 @@ public class History { private SearchRepository searchRepository; @Autowired private IndexerSearchRepository indexerSearchRepository; + @Autowired + private ConfigProvider configProvider; @Transactional public Page getHistory(HistoryRequest requestData, String tableName, Class resultClass) { @@ -161,7 +164,7 @@ public List getHistoryForSearching() { } contained.add(hash); entities.add(searchEntity); - if (entities.size() == 25) { + if (entities.size() == configProvider.getBaseConfig().getSearching().getHistoryForSearching()) { break; } } diff --git a/core/src/main/resources/changelog.yaml b/core/src/main/resources/changelog.yaml index 5dd1a5baf..7aa43c9fb 100644 --- a/core/src/main/resources/changelog.yaml +++ b/core/src/main/resources/changelog.yaml @@ -1,4 +1,10 @@ #@formatter:off +- version: "v7.7.0" + date: "2024-10-03" + changes: + - type: "feature" + text: "Configure the number of recent searches shown in the search bar dropdown." + final: true - version: "v7.6.0" date: "2024-09-15" changes: diff --git a/core/ui-src/js/config/config-fields-service.js b/core/ui-src/js/config/config-fields-service.js index e00d09fed..5d61a1e02 100644 --- a/core/ui-src/js/config/config-fields-service.js +++ b/core/ui-src/js/config/config-fields-service.js @@ -1520,6 +1520,15 @@ function ConfigFields($injector) { required: true, tooltip: 'Found results are stored in the database for this long until they\'re deleted. After that any links to Hydra results still stored elsewhere become invalid. You can increase the limit if you want, the disc space needed is negligible (about 75 MB for 7 days on my server).' } + }, { + key: 'historyForSearching', + type: 'horizontalInput', + templateOptions: { + type: 'number', + label: 'Recet searches in search bar', + required: true, + tooltip: 'The number of recent searches shown in the search bar dropdown (the icon).' + } }, { key: 'globalCacheTimeMinutes', diff --git a/shared/mapping/src/main/java/org/nzbhydra/config/SearchingConfig.java b/shared/mapping/src/main/java/org/nzbhydra/config/SearchingConfig.java index f4fa10999..27be66f2f 100644 --- a/shared/mapping/src/main/java/org/nzbhydra/config/SearchingConfig.java +++ b/shared/mapping/src/main/java/org/nzbhydra/config/SearchingConfig.java @@ -52,8 +52,8 @@ public class SearchingConfig { private List forbiddenWords = new ArrayList<>(); private SearchSourceRestriction alwaysConvertIds = SearchSourceRestriction.NONE; private SearchSourceRestriction generateQueries = SearchSourceRestriction.INTERNAL; - private QueryFormat generateQueriesFormat = QueryFormat.TITLE; + private int historyForSearching = 25; @JsonFormat(shape = Shape.STRING) private SearchSourceRestriction idFallbackToQueryGeneration = SearchSourceRestriction.NONE; private boolean ignorePassworded = false;