From 6e638cd6730b936a0611c469ac2cbb125e7d320b Mon Sep 17 00:00:00 2001 From: Alex Date: Sun, 30 Oct 2022 11:03:17 -0500 Subject: [PATCH] fix(web) getting asset with avaialble thumbnail when getting asset count by time bucket (#900) --- .../immich/src/api-v1/asset/asset-repository.ts | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/server/apps/immich/src/api-v1/asset/asset-repository.ts b/server/apps/immich/src/api-v1/asset/asset-repository.ts index ed6c05a09c..6211caa838 100644 --- a/server/apps/immich/src/api-v1/asset/asset-repository.ts +++ b/server/apps/immich/src/api-v1/asset/asset-repository.ts @@ -35,7 +35,10 @@ export interface IAssetRepository { getAssetWithNoThumbnail(): Promise; getAssetWithNoEXIF(): Promise; getAssetWithNoSmartInfo(): Promise; - getExistingAssets(userId: string, checkDuplicateAssetDto: CheckExistingAssetsDto): Promise; + getExistingAssets( + userId: string, + checkDuplicateAssetDto: CheckExistingAssetsDto, + ): Promise; } export const ASSET_REPOSITORY = 'ASSET_REPOSITORY'; @@ -118,6 +121,7 @@ export class AssetRepository implements IAssetRepository { .select(`COUNT(asset.id)::int`, 'count') .addSelect(`date_trunc('month', "createdAt")`, 'timeBucket') .where('"userId" = :userId', { userId: userId }) + .andWhere('asset.resizePath is not NULL') .groupBy(`date_trunc('month', "createdAt")`) .orderBy(`date_trunc('month', "createdAt")`, 'DESC') .getRawMany(); @@ -127,6 +131,7 @@ export class AssetRepository implements IAssetRepository { .select(`COUNT(asset.id)::int`, 'count') .addSelect(`date_trunc('day', "createdAt")`, 'timeBucket') .where('"userId" = :userId', { userId: userId }) + .andWhere('asset.resizePath is not NULL') .groupBy(`date_trunc('day', "createdAt")`) .orderBy(`date_trunc('day', "createdAt")`, 'DESC') .getRawMany(); @@ -284,16 +289,18 @@ export class AssetRepository implements IAssetRepository { }); } - async getExistingAssets(userId: string, checkDuplicateAssetDto: CheckExistingAssetsDto): Promise { + async getExistingAssets( + userId: string, + checkDuplicateAssetDto: CheckExistingAssetsDto, + ): Promise { const existingAssets = await this.assetRepository.find({ - select: {deviceAssetId: true}, + select: { deviceAssetId: true }, where: { deviceAssetId: In(checkDuplicateAssetDto.deviceAssetIds), deviceId: checkDuplicateAssetDto.deviceId, userId, }, }); - return new CheckExistingAssetsResponseDto(existingAssets.map(a => a.deviceAssetId)); + return new CheckExistingAssetsResponseDto(existingAssets.map((a) => a.deviceAssetId)); } - }