mirror of
https://github.com/immich-app/immich.git
synced 2025-12-27 09:14:55 +03:00
fix(server): search suggestions include partner assets (#12269)
search suggestions now include partner assets Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
@@ -103,7 +103,7 @@ describe(SearchService.name, () => {
|
||||
await expect(
|
||||
sut.getSearchSuggestions(authStub.user1, { includeNull: true, type: SearchSuggestionType.COUNTRY }),
|
||||
).resolves.toEqual(['USA', null]);
|
||||
expect(metadataMock.getCountries).toHaveBeenCalledWith(authStub.user1.user.id);
|
||||
expect(metadataMock.getCountries).toHaveBeenCalledWith([authStub.user1.user.id]);
|
||||
});
|
||||
|
||||
it('should return search suggestions (without null)', async () => {
|
||||
@@ -111,7 +111,7 @@ describe(SearchService.name, () => {
|
||||
await expect(
|
||||
sut.getSearchSuggestions(authStub.user1, { includeNull: false, type: SearchSuggestionType.COUNTRY }),
|
||||
).resolves.toEqual(['USA']);
|
||||
expect(metadataMock.getCountries).toHaveBeenCalledWith(authStub.user1.user.id);
|
||||
expect(metadataMock.getCountries).toHaveBeenCalledWith([authStub.user1.user.id]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -121,26 +121,27 @@ export class SearchService {
|
||||
}
|
||||
|
||||
async getSearchSuggestions(auth: AuthDto, dto: SearchSuggestionRequestDto) {
|
||||
const results = await this.getSuggestions(auth.user.id, dto);
|
||||
const userIds = await this.getUserIdsToSearch(auth);
|
||||
const results = await this.getSuggestions(userIds, dto);
|
||||
return results.filter((result) => (dto.includeNull ? true : result !== null));
|
||||
}
|
||||
|
||||
private getSuggestions(userId: string, dto: SearchSuggestionRequestDto) {
|
||||
private getSuggestions(userIds: string[], dto: SearchSuggestionRequestDto) {
|
||||
switch (dto.type) {
|
||||
case SearchSuggestionType.COUNTRY: {
|
||||
return this.metadataRepository.getCountries(userId);
|
||||
return this.metadataRepository.getCountries(userIds);
|
||||
}
|
||||
case SearchSuggestionType.STATE: {
|
||||
return this.metadataRepository.getStates(userId, dto.country);
|
||||
return this.metadataRepository.getStates(userIds, dto.country);
|
||||
}
|
||||
case SearchSuggestionType.CITY: {
|
||||
return this.metadataRepository.getCities(userId, dto.country, dto.state);
|
||||
return this.metadataRepository.getCities(userIds, dto.country, dto.state);
|
||||
}
|
||||
case SearchSuggestionType.CAMERA_MAKE: {
|
||||
return this.metadataRepository.getCameraMakes(userId, dto.model);
|
||||
return this.metadataRepository.getCameraMakes(userIds, dto.model);
|
||||
}
|
||||
case SearchSuggestionType.CAMERA_MODEL: {
|
||||
return this.metadataRepository.getCameraModels(userId, dto.make);
|
||||
return this.metadataRepository.getCameraModels(userIds, dto.make);
|
||||
}
|
||||
default: {
|
||||
return [];
|
||||
|
||||
Reference in New Issue
Block a user