mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
feat: album map markers endpoint (#27830)
This commit is contained in:
@@ -76,29 +76,21 @@ export class MapRepository {
|
||||
this.logger.log('Geodata import completed');
|
||||
}
|
||||
|
||||
@GenerateSql({ params: [DummyValue.UUID] })
|
||||
getAlbumMapMarkers(albumId: string) {
|
||||
return this.mapMarkersQuery()
|
||||
.innerJoin('album_asset', 'asset.id', 'album_asset.assetId')
|
||||
.where('album_asset.albumId', '=', albumId)
|
||||
.execute();
|
||||
}
|
||||
|
||||
@GenerateSql({ params: [[DummyValue.UUID], [DummyValue.UUID]] })
|
||||
getMapMarkers(
|
||||
ownerIds: string[],
|
||||
albumIds: string[],
|
||||
{ isArchived, isFavorite, fileCreatedAfter, fileCreatedBefore }: MapMarkerSearchOptions = {},
|
||||
) {
|
||||
return this.db
|
||||
.selectFrom('asset')
|
||||
.innerJoin('asset_exif', (builder) =>
|
||||
builder
|
||||
.onRef('asset.id', '=', 'asset_exif.assetId')
|
||||
.on('asset_exif.latitude', 'is not', null)
|
||||
.on('asset_exif.longitude', 'is not', null),
|
||||
)
|
||||
.select([
|
||||
'id',
|
||||
'asset_exif.latitude as lat',
|
||||
'asset_exif.longitude as lon',
|
||||
'asset_exif.city',
|
||||
'asset_exif.state',
|
||||
'asset_exif.country',
|
||||
])
|
||||
.$narrowType<{ lat: NotNull; lon: NotNull }>()
|
||||
return this.mapMarkersQuery()
|
||||
.$if(isArchived === true, (qb) =>
|
||||
qb.where((eb) =>
|
||||
eb.or([
|
||||
@@ -113,7 +105,6 @@ export class MapRepository {
|
||||
.$if(isFavorite !== undefined, (q) => q.where('isFavorite', '=', isFavorite!))
|
||||
.$if(fileCreatedAfter !== undefined, (q) => q.where('fileCreatedAt', '>=', fileCreatedAfter!))
|
||||
.$if(fileCreatedBefore !== undefined, (q) => q.where('fileCreatedAt', '<=', fileCreatedBefore!))
|
||||
.where('deletedAt', 'is', null)
|
||||
.where((eb) => {
|
||||
const expression: Expression<SqlBool>[] = [];
|
||||
|
||||
@@ -134,10 +125,31 @@ export class MapRepository {
|
||||
|
||||
return eb.or(expression);
|
||||
})
|
||||
.orderBy('fileCreatedAt', 'desc')
|
||||
.execute();
|
||||
}
|
||||
|
||||
private mapMarkersQuery() {
|
||||
return this.db
|
||||
.selectFrom('asset')
|
||||
.innerJoin('asset_exif', (builder) =>
|
||||
builder
|
||||
.onRef('asset.id', '=', 'asset_exif.assetId')
|
||||
.on('asset_exif.latitude', 'is not', null)
|
||||
.on('asset_exif.longitude', 'is not', null),
|
||||
)
|
||||
.where('asset.deletedAt', 'is', null)
|
||||
.orderBy('fileCreatedAt', 'desc')
|
||||
.select([
|
||||
'id',
|
||||
'asset_exif.latitude as lat',
|
||||
'asset_exif.longitude as lon',
|
||||
'asset_exif.city',
|
||||
'asset_exif.state',
|
||||
'asset_exif.country',
|
||||
])
|
||||
.$narrowType<{ lat: NotNull; lon: NotNull }>();
|
||||
}
|
||||
|
||||
async reverseGeocode(point: GeoPoint): Promise<ReverseGeocodeResult> {
|
||||
this.logger.debug(`Request: ${point.latitude},${point.longitude}`);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user