Browse Source

fix: use fileCreatedAt for asset sorting after recent refactor (#1799)

Zack Pollard 2 years ago
parent
commit
824409351e
1 changed files with 8 additions and 8 deletions
  1. 8 8
      server/apps/immich/src/api-v1/asset/asset-repository.ts

+ 8 - 8
server/apps/immich/src/api-v1/asset/asset-repository.ts

@@ -152,12 +152,12 @@ export class AssetRepository implements IAssetRepository {
     return await this.assetRepository
     return await this.assetRepository
       .createQueryBuilder('asset')
       .createQueryBuilder('asset')
       .where('asset.ownerId = :userId', { userId: userId })
       .where('asset.ownerId = :userId', { userId: userId })
-      .andWhere(`date_trunc('month', "createdAt") IN (:...buckets)`, {
+      .andWhere(`date_trunc('month', "fileCreatedAt") IN (:...buckets)`, {
         buckets: [...getAssetByTimeBucketDto.timeBucket],
         buckets: [...getAssetByTimeBucketDto.timeBucket],
       })
       })
       .andWhere('asset.resizePath is not NULL')
       .andWhere('asset.resizePath is not NULL')
       .andWhere('asset.isVisible = true')
       .andWhere('asset.isVisible = true')
-      .orderBy('asset.createdAt', 'DESC')
+      .orderBy('asset.fileCreatedAt', 'DESC')
       .getMany();
       .getMany();
   }
   }
 
 
@@ -168,23 +168,23 @@ export class AssetRepository implements IAssetRepository {
       result = await this.assetRepository
       result = await this.assetRepository
         .createQueryBuilder('asset')
         .createQueryBuilder('asset')
         .select(`COUNT(asset.id)::int`, 'count')
         .select(`COUNT(asset.id)::int`, 'count')
-        .addSelect(`date_trunc('month', "createdAt")`, 'timeBucket')
+        .addSelect(`date_trunc('month', "fileCreatedAt")`, 'timeBucket')
         .where('"ownerId" = :userId', { userId: userId })
         .where('"ownerId" = :userId', { userId: userId })
         .andWhere('asset.resizePath is not NULL')
         .andWhere('asset.resizePath is not NULL')
         .andWhere('asset.isVisible = true')
         .andWhere('asset.isVisible = true')
-        .groupBy(`date_trunc('month', "createdAt")`)
-        .orderBy(`date_trunc('month', "createdAt")`, 'DESC')
+        .groupBy(`date_trunc('month', "fileCreatedAt")`)
+        .orderBy(`date_trunc('month', "fileCreatedAt")`, 'DESC')
         .getRawMany();
         .getRawMany();
     } else if (timeBucket === TimeGroupEnum.Day) {
     } else if (timeBucket === TimeGroupEnum.Day) {
       result = await this.assetRepository
       result = await this.assetRepository
         .createQueryBuilder('asset')
         .createQueryBuilder('asset')
         .select(`COUNT(asset.id)::int`, 'count')
         .select(`COUNT(asset.id)::int`, 'count')
-        .addSelect(`date_trunc('day', "createdAt")`, 'timeBucket')
+        .addSelect(`date_trunc('day', "fileCreatedAt")`, 'timeBucket')
         .where('"ownerId" = :userId', { userId: userId })
         .where('"ownerId" = :userId', { userId: userId })
         .andWhere('asset.resizePath is not NULL')
         .andWhere('asset.resizePath is not NULL')
         .andWhere('asset.isVisible = true')
         .andWhere('asset.isVisible = true')
-        .groupBy(`date_trunc('day', "createdAt")`)
-        .orderBy(`date_trunc('day', "createdAt")`, 'DESC')
+        .groupBy(`date_trunc('day', "fileCreatedAt")`)
+        .orderBy(`date_trunc('day', "fileCreatedAt")`, 'DESC')
         .getRawMany();
         .getRawMany();
     }
     }