Skip to content

Commit

Permalink
Configure the number of recent searches shown in the search bar dropd…
Browse files Browse the repository at this point in the history
…own.
  • Loading branch information
theotherp committed Oct 3, 2024
1 parent b2b839b commit d31238e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
5 changes: 4 additions & 1 deletion core/src/main/java/org/nzbhydra/historystats/History.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,6 +49,8 @@ public class History {
private SearchRepository searchRepository;
@Autowired
private IndexerSearchRepository indexerSearchRepository;
@Autowired
private ConfigProvider configProvider;

@Transactional
public <T> Page<T> getHistory(HistoryRequest requestData, String tableName, Class<T> resultClass) {
Expand Down Expand Up @@ -161,7 +164,7 @@ public List<SearchEntity> getHistoryForSearching() {
}
contained.add(hash);
entities.add(searchEntity);
if (entities.size() == 25) {
if (entities.size() == configProvider.getBaseConfig().getSearching().getHistoryForSearching()) {
break;
}
}
Expand Down
6 changes: 6 additions & 0 deletions core/src/main/resources/changelog.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
9 changes: 9 additions & 0 deletions core/ui-src/js/config/config-fields-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 <span class="glyphicon glyphicon-time"></span> icon).'
}
},
{
key: 'globalCacheTimeMinutes',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public class SearchingConfig {
private List<String> 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;
Expand Down

0 comments on commit d31238e

Please sign in to comment.