refactor(server): use includeNull in query for search suggestions (#14626)
* use `includeNull` * push down `includeNull` into query, inner joins * remove filter * update sql * fix tests * maybe fix e2e * more e2e tests * handle no exif row * whoops * update sql
This commit is contained in:
@@ -108,8 +108,11 @@ export class SearchService extends BaseService {
|
||||
|
||||
async getSearchSuggestions(auth: AuthDto, dto: SearchSuggestionRequestDto) {
|
||||
const userIds = await this.getUserIdsToSearch(auth);
|
||||
const results = await this.getSuggestions(userIds, dto);
|
||||
return results.filter((result) => (dto.includeNull ? true : result !== null));
|
||||
const suggestions = await this.getSuggestions(userIds, dto);
|
||||
if (dto.includeNull) {
|
||||
suggestions.push(null);
|
||||
}
|
||||
return suggestions;
|
||||
}
|
||||
|
||||
private getSuggestions(userIds: string[], dto: SearchSuggestionRequestDto) {
|
||||
@@ -118,19 +121,19 @@ export class SearchService extends BaseService {
|
||||
return this.searchRepository.getCountries(userIds);
|
||||
}
|
||||
case SearchSuggestionType.STATE: {
|
||||
return this.searchRepository.getStates(userIds, dto.country);
|
||||
return this.searchRepository.getStates(userIds, dto);
|
||||
}
|
||||
case SearchSuggestionType.CITY: {
|
||||
return this.searchRepository.getCities(userIds, dto.country, dto.state);
|
||||
return this.searchRepository.getCities(userIds, dto);
|
||||
}
|
||||
case SearchSuggestionType.CAMERA_MAKE: {
|
||||
return this.searchRepository.getCameraMakes(userIds, dto.model);
|
||||
return this.searchRepository.getCameraMakes(userIds, dto);
|
||||
}
|
||||
case SearchSuggestionType.CAMERA_MODEL: {
|
||||
return this.searchRepository.getCameraModels(userIds, dto.make);
|
||||
return this.searchRepository.getCameraModels(userIds, dto);
|
||||
}
|
||||
default: {
|
||||
return [];
|
||||
return [] as (string | null)[];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user