From e3d08f08564e09648f03ba03cde5c385342fc768 Mon Sep 17 00:00:00 2001 From: mertalev <101130780+mertalev@users.noreply.github.com> Date: Fri, 20 Dec 2024 17:18:06 -0500 Subject: [PATCH] fixes for sync queries --- server/src/repositories/asset.repository.ts | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/server/src/repositories/asset.repository.ts b/server/src/repositories/asset.repository.ts index bd02601b25..f5f9d47179 100644 --- a/server/src/repositories/asset.repository.ts +++ b/server/src/repositories/asset.repository.ts @@ -685,6 +685,9 @@ export class AssetRepository implements IAssetRepository { const { ownerId, lastId, updatedUntil, limit } = options; return this.db .selectFrom('assets') + .selectAll('assets') + .$call(withExif) + .$call((qb) => withStack(qb, { assets: false })) .where('ownerId', '=', asUuid(ownerId)) .where('isVisible', '=', true) .where('updatedAt', '<=', updatedUntil) @@ -699,13 +702,8 @@ export class AssetRepository implements IAssetRepository { return this.db .selectFrom('assets') .selectAll('assets') - .select((eb) => - eb - .selectFrom('asset_stack') - .select((eb) => eb.fn.countAll().as('stackedAssetsCount')) - .whereRef('asset_stack.id', '=', 'assets.stackId') - .as('stackedAssetsCount'), - ) + .$call(withExif) + .$call((qb) => withStack(qb, { assets: false })) .where('ownerId', '=', anyUuid(options.userIds)) .where('isVisible', '=', true) .where('updatedAt', '>', options.updatedAfter)