1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-12-18 00:19:25 +02:00

adding caption support

This commit is contained in:
Patrik J. Braun
2018-12-05 19:15:24 +01:00
parent 7692c455bc
commit 8e18abd2bd
12 changed files with 73 additions and 11 deletions

View File

@@ -70,6 +70,16 @@ export class SearchManager implements ISearchManager {
.getRawMany())
.map(r => r.name), SearchTypes.photo));
result = result.concat(this.encapsulateAutoComplete((await photoRepository
.createQueryBuilder('media')
.select('DISTINCT(media.metadata.caption) as caption')
.where('media.metadata.caption LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
.limit(5)
.getRawMany())
.map(r => r.caption), SearchTypes.photo));
result = result.concat(this.encapsulateAutoComplete((await videoRepository
.createQueryBuilder('media')
.select('DISTINCT(media.name)')
@@ -123,6 +133,10 @@ export class SearchManager implements ISearchManager {
query.orWhere('media.name LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'});
}
if (!searchType || searchType === SearchTypes.photo) {
query.orWhere('media.metadata.caption LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'});
}
if (!searchType || searchType === SearchTypes.position) {
query.orWhere('media.metadata.positionData.country LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
.orWhere('media.metadata.positionData.state LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
@@ -176,6 +190,7 @@ export class SearchManager implements ISearchManager {
.orWhere('media.metadata.positionData.state LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
.orWhere('media.metadata.positionData.city LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
.orWhere('media.name LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
.orWhere('media.metadata.caption LIKE :text COLLATE utf8_general_ci', {text: '%' + text + '%'})
.innerJoinAndSelect('media.directory', 'directory')
.limit(10)
.getMany();