feat(web): add search filter for camera lens model. (#21792)

This commit is contained in:
Dag Stuan
2025-10-24 20:41:34 +02:00
committed by GitHub
parent d9cddeb0f1
commit 78fb815cdb
12 changed files with 133 additions and 15 deletions

View File

@@ -160,10 +160,17 @@ export interface GetCitiesOptions extends GetStatesOptions {
export interface GetCameraModelsOptions {
make?: string;
lensModel?: string;
}
export interface GetCameraMakesOptions {
model?: string;
lensModel?: string;
}
export interface GetCameraLensModelsOptions {
make?: string;
model?: string;
}
@Injectable()
@@ -457,25 +464,40 @@ export class SearchRepository {
return res.map((row) => row.city!);
}
@GenerateSql({ params: [[DummyValue.UUID], DummyValue.STRING] })
async getCameraMakes(userIds: string[], { model }: GetCameraMakesOptions): Promise<string[]> {
@GenerateSql({ params: [[DummyValue.UUID], DummyValue.STRING, DummyValue.STRING] })
async getCameraMakes(userIds: string[], { model, lensModel }: GetCameraMakesOptions): Promise<string[]> {
const res = await this.getExifField('make', userIds)
.$if(!!model, (qb) => qb.where('model', '=', model!))
.$if(!!lensModel, (qb) => qb.where('lensModel', '=', lensModel!))
.execute();
return res.map((row) => row.make!);
}
@GenerateSql({ params: [[DummyValue.UUID], DummyValue.STRING] })
async getCameraModels(userIds: string[], { make }: GetCameraModelsOptions): Promise<string[]> {
@GenerateSql({ params: [[DummyValue.UUID], DummyValue.STRING, DummyValue.STRING] })
async getCameraModels(userIds: string[], { make, lensModel }: GetCameraModelsOptions): Promise<string[]> {
const res = await this.getExifField('model', userIds)
.$if(!!make, (qb) => qb.where('make', '=', make!))
.$if(!!lensModel, (qb) => qb.where('lensModel', '=', lensModel!))
.execute();
return res.map((row) => row.model!);
}
private getExifField<K extends 'city' | 'state' | 'country' | 'make' | 'model'>(field: K, userIds: string[]) {
@GenerateSql({ params: [[DummyValue.UUID], DummyValue.STRING] })
async getCameraLensModels(userIds: string[], { make, model }: GetCameraLensModelsOptions): Promise<string[]> {
const res = await this.getExifField('lensModel', userIds)
.$if(!!make, (qb) => qb.where('make', '=', make!))
.$if(!!model, (qb) => qb.where('model', '=', model!))
.execute();
return res.map((row) => row.lensModel!);
}
private getExifField<K extends 'city' | 'state' | 'country' | 'make' | 'model' | 'lensModel'>(
field: K,
userIds: string[],
) {
return this.db
.selectFrom('asset_exif')
.select(field)