1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Refactoring max search result.

#174
This commit is contained in:
Patrik J. Braun 2020-10-31 21:16:51 +01:00
parent 7571788bc7
commit ee355dd012
2 changed files with 8 additions and 4 deletions

View File

@ -137,7 +137,7 @@ export class SearchManager implements ISearchManager {
.innerJoin(q => { .innerJoin(q => {
const subQuery = q.from(usedEntity, 'media') const subQuery = q.from(usedEntity, 'media')
.select('distinct media.id') .select('distinct media.id')
.limit(2000); .limit(Config.Client.Search.maxMediaResult + 1);
if (!searchType || searchType === SearchTypes.directory) { if (!searchType || searchType === SearchTypes.directory) {
@ -180,7 +180,7 @@ export class SearchManager implements ISearchManager {
result.media = await this.loadMediaWithFaces(query); result.media = await this.loadMediaWithFaces(query);
if (result.media.length > 2000) { if (result.media.length > Config.Client.Search.maxMediaResult) {
result.resultOverflow = true; result.resultOverflow = true;
} }
@ -188,10 +188,10 @@ export class SearchManager implements ISearchManager {
.getRepository(DirectoryEntity) .getRepository(DirectoryEntity)
.createQueryBuilder('dir') .createQueryBuilder('dir')
.where('dir.name LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'}) .where('dir.name LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
.limit(201) .limit(Config.Client.Search.maxMediaResult + 1)
.getMany(); .getMany();
if (result.directories.length > 200) { if (result.directories.length > Config.Client.Search.maxDirectoryResult) {
result.resultOverflow = true; result.resultOverflow = true;
} }

View File

@ -35,6 +35,10 @@ export module ClientConfig {
searchCacheTimeout: number = 1000 * 60 * 60; searchCacheTimeout: number = 1000 * 60 * 60;
@ConfigProperty() @ConfigProperty()
AutoComplete: AutoCompleteConfig = new AutoCompleteConfig(); AutoComplete: AutoCompleteConfig = new AutoCompleteConfig();
@ConfigProperty({type: 'unsignedInt'})
maxMediaResult: number = 2000;
@ConfigProperty({type: 'unsignedInt'})
maxDirectoryResult: number = 200;
} }
@SubConfigClass() @SubConfigClass()