mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
improving mass search handling
This commit is contained in:
parent
7d146cac87
commit
e0f8f0d722
@ -70,7 +70,8 @@ export class SearchManager implements ISearchManager {
|
||||
searchText: text,
|
||||
searchType: searchType,
|
||||
directories: [],
|
||||
photos: []
|
||||
photos: [],
|
||||
resultOverflow: false
|
||||
};
|
||||
|
||||
let query = connection
|
||||
@ -95,6 +96,7 @@ export class SearchManager implements ISearchManager {
|
||||
query.orWhere('photo.metadata.keywords LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"});
|
||||
}
|
||||
let photos = await query
|
||||
.setLimit(2001)
|
||||
.getMany();
|
||||
|
||||
|
||||
@ -106,14 +108,21 @@ export class SearchManager implements ISearchManager {
|
||||
photos[i].metadata.size = <any>JSON.parse(<any>photos[i].metadata.size);
|
||||
}
|
||||
result.photos = photos;
|
||||
if (result.photos.length > 2000) {
|
||||
result.resultOverflow = true;
|
||||
}
|
||||
}
|
||||
|
||||
result.directories = await connection
|
||||
.getRepository(DirectoryEntity)
|
||||
.createQueryBuilder("dir")
|
||||
.where('dir.name LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"})
|
||||
.setLimit(201)
|
||||
.getMany();
|
||||
|
||||
if (result.directories.length > 200) {
|
||||
result.resultOverflow = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -124,7 +133,8 @@ export class SearchManager implements ISearchManager {
|
||||
let result: SearchResultDTO = <SearchResultDTO>{
|
||||
searchText: text,
|
||||
directories: [],
|
||||
photos: []
|
||||
photos: [],
|
||||
resultOverflow: false
|
||||
};
|
||||
|
||||
let photos = await connection
|
||||
|
@ -7,4 +7,5 @@ export interface SearchResultDTO {
|
||||
searchType: SearchTypes;
|
||||
directories: Array<DirectoryDTO>;
|
||||
photos: Array<PhotoDTO>;
|
||||
resultOverflow: boolean;
|
||||
}
|
||||
|
@ -31,6 +31,10 @@
|
||||
</div>
|
||||
|
||||
<div body class="container" style="width: 100%; padding:0" *ngIf="_galleryService.content.value.searchResult">
|
||||
<div class="alert alert-info" role="alert"
|
||||
*ngIf="_galleryService.content.value.searchResult.resultOverflow == true">
|
||||
Too many results to show. Refine your search.
|
||||
</div>
|
||||
<ol class="breadcrumb">
|
||||
<li class="active">
|
||||
Searching for:
|
||||
|
@ -82,6 +82,8 @@ export class GalleryService {
|
||||
}
|
||||
|
||||
const cw: ContentWrapper = await this.networkService.getJson<ContentWrapper>("/search/" + text, {type: type});
|
||||
console.log("photos", cw.searchResult.photos.length);
|
||||
console.log("direcotries", cw.searchResult.directories.length);
|
||||
this.content.next(cw);
|
||||
return cw;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user