mirror of
https://github.com/immich-app/immich.git
synced 2026-03-07 10:37:22 +03:00
fix(server): assets in multiple albums duplicated in map view (#16245)
This commit is contained in:
@@ -76,7 +76,7 @@ export class MapRepository {
|
||||
this.logger.log('Geodata import completed');
|
||||
}
|
||||
|
||||
@GenerateSql({ params: [[DummyValue.UUID], []] })
|
||||
@GenerateSql({ params: [[DummyValue.UUID], [DummyValue.UUID]] })
|
||||
getMapMarkers(ownerIds: string[], albumIds: string[], options: MapMarkerSearchOptions = {}) {
|
||||
const { isArchived, isFavorite, fileCreatedAfter, fileCreatedBefore } = options;
|
||||
|
||||
@@ -89,25 +89,31 @@ export class MapRepository {
|
||||
.on('exif.longitude', 'is not', null),
|
||||
)
|
||||
.select(['id', 'exif.latitude as lat', 'exif.longitude as lon', 'exif.city', 'exif.state', 'exif.country'])
|
||||
.leftJoin('albums_assets_assets', (join) => join.onRef('assets.id', '=', 'albums_assets_assets.assetsId'))
|
||||
.where('isVisible', '=', true)
|
||||
.$if(isArchived !== undefined, (q) => q.where('isArchived', '=', isArchived!))
|
||||
.$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((builder) => {
|
||||
.where((eb) => {
|
||||
const expression: Expression<SqlBool>[] = [];
|
||||
|
||||
if (ownerIds.length > 0) {
|
||||
expression.push(builder('ownerId', 'in', ownerIds));
|
||||
expression.push(eb('ownerId', 'in', ownerIds));
|
||||
}
|
||||
|
||||
if (albumIds.length > 0) {
|
||||
expression.push(builder('albums_assets_assets.albumsId', 'in', albumIds));
|
||||
expression.push(
|
||||
eb.exists((eb) =>
|
||||
eb
|
||||
.selectFrom('albums_assets_assets')
|
||||
.whereRef('assets.id', '=', 'albums_assets_assets.assetsId')
|
||||
.where('albums_assets_assets.albumsId', 'in', albumIds),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return builder.or(expression);
|
||||
return eb.or(expression);
|
||||
})
|
||||
.orderBy('fileCreatedAt', 'desc')
|
||||
.execute() as Promise<MapMarker[]>;
|
||||
|
||||
Reference in New Issue
Block a user