mirror of
https://github.com/bpatrik/pigallery2.git
synced 2025-01-06 03:54:12 +02:00
improving mass search handling
This commit is contained in:
parent
7d146cac87
commit
e0f8f0d722
@ -63,14 +63,15 @@ export class SearchManager implements ISearchManager {
|
|||||||
return this.autoCompleteItemsUnique(result);
|
return this.autoCompleteItemsUnique(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
async search(text: string, searchType: SearchTypes) {
|
async search(text: string, searchType: SearchTypes) {
|
||||||
const connection = await SQLConnection.getConnection();
|
const connection = await SQLConnection.getConnection();
|
||||||
|
|
||||||
let result: SearchResultDTO = <SearchResultDTO>{
|
let result: SearchResultDTO = <SearchResultDTO>{
|
||||||
searchText: text,
|
searchText: text,
|
||||||
searchType: searchType,
|
searchType: searchType,
|
||||||
directories: [],
|
directories: [],
|
||||||
photos: []
|
photos: [],
|
||||||
|
resultOverflow: false
|
||||||
};
|
};
|
||||||
|
|
||||||
let query = connection
|
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 + "%"});
|
query.orWhere('photo.metadata.keywords LIKE :text COLLATE utf8_general_ci', {text: "%" + text + "%"});
|
||||||
}
|
}
|
||||||
let photos = await query
|
let photos = await query
|
||||||
|
.setLimit(2001)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
|
|
||||||
@ -106,25 +108,33 @@ export class SearchManager implements ISearchManager {
|
|||||||
photos[i].metadata.size = <any>JSON.parse(<any>photos[i].metadata.size);
|
photos[i].metadata.size = <any>JSON.parse(<any>photos[i].metadata.size);
|
||||||
}
|
}
|
||||||
result.photos = photos;
|
result.photos = photos;
|
||||||
|
if (result.photos.length > 2000) {
|
||||||
|
result.resultOverflow = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result.directories = await connection
|
result.directories = await connection
|
||||||
.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 + "%"})
|
||||||
|
.setLimit(201)
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
|
if (result.directories.length > 200) {
|
||||||
|
result.resultOverflow = true;
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
async instantSearch(text: string) {
|
async instantSearch(text: string) {
|
||||||
const connection = await SQLConnection.getConnection();
|
const connection = await SQLConnection.getConnection();
|
||||||
|
|
||||||
let result: SearchResultDTO = <SearchResultDTO>{
|
let result: SearchResultDTO = <SearchResultDTO>{
|
||||||
searchText: text,
|
searchText: text,
|
||||||
directories: [],
|
directories: [],
|
||||||
photos: []
|
photos: [],
|
||||||
|
resultOverflow: false
|
||||||
};
|
};
|
||||||
|
|
||||||
let photos = await connection
|
let photos = await connection
|
||||||
|
@ -7,4 +7,5 @@ export interface SearchResultDTO {
|
|||||||
searchType: SearchTypes;
|
searchType: SearchTypes;
|
||||||
directories: Array<DirectoryDTO>;
|
directories: Array<DirectoryDTO>;
|
||||||
photos: Array<PhotoDTO>;
|
photos: Array<PhotoDTO>;
|
||||||
|
resultOverflow: boolean;
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,10 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div body class="container" style="width: 100%; padding:0" *ngIf="_galleryService.content.value.searchResult">
|
<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">
|
<ol class="breadcrumb">
|
||||||
<li class="active">
|
<li class="active">
|
||||||
Searching for:
|
Searching for:
|
||||||
|
@ -82,6 +82,8 @@ export class GalleryService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const cw: ContentWrapper = await this.networkService.getJson<ContentWrapper>("/search/" + text, {type: type});
|
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);
|
this.content.next(cw);
|
||||||
return cw;
|
return cw;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user