mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-04 03:27:09 -05:00 
			
		
		
		
	chore(server): set relations for getByIds (#4855)
				
					
				
			This commit is contained in:
		
							parent
							
								
									a0743d8b7d
								
							
						
					
					
						commit
						9e7a32804b
					
				@ -216,7 +216,13 @@ export class PersonService {
 | 
				
			|||||||
      return true;
 | 
					      return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const [asset] = await this.assetRepository.getByIds([id]);
 | 
					    const relations = {
 | 
				
			||||||
 | 
					      exifInfo: true,
 | 
				
			||||||
 | 
					      faces: {
 | 
				
			||||||
 | 
					        person: true,
 | 
				
			||||||
 | 
					      },
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
 | 
					    const [asset] = await this.assetRepository.getByIds([id], relations);
 | 
				
			||||||
    if (!asset || !asset.resizePath || asset.faces?.length > 0) {
 | 
					    if (!asset || !asset.resizePath || asset.faces?.length > 0) {
 | 
				
			||||||
      return false;
 | 
					      return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -1,4 +1,5 @@
 | 
				
			|||||||
import { AssetEntity, AssetType, ExifEntity } from '@app/infra/entities';
 | 
					import { AssetEntity, AssetType, ExifEntity } from '@app/infra/entities';
 | 
				
			||||||
 | 
					import { FindOptionsRelations } from 'typeorm';
 | 
				
			||||||
import { Paginated, PaginationOptions } from '../domain.util';
 | 
					import { Paginated, PaginationOptions } from '../domain.util';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export type AssetStats = Record<AssetType, number>;
 | 
					export type AssetStats = Record<AssetType, number>;
 | 
				
			||||||
@ -99,7 +100,7 @@ export const IAssetRepository = 'IAssetRepository';
 | 
				
			|||||||
export interface IAssetRepository {
 | 
					export interface IAssetRepository {
 | 
				
			||||||
  create(asset: AssetCreate): Promise<AssetEntity>;
 | 
					  create(asset: AssetCreate): Promise<AssetEntity>;
 | 
				
			||||||
  getByDate(ownerId: string, date: Date): Promise<AssetEntity[]>;
 | 
					  getByDate(ownerId: string, date: Date): Promise<AssetEntity[]>;
 | 
				
			||||||
  getByIds(ids: string[]): Promise<AssetEntity[]>;
 | 
					  getByIds(ids: string[], relations?: FindOptionsRelations<AssetEntity>): Promise<AssetEntity[]>;
 | 
				
			||||||
  getByDayOfYear(ownerId: string, monthDay: MonthDay): Promise<AssetEntity[]>;
 | 
					  getByDayOfYear(ownerId: string, monthDay: MonthDay): Promise<AssetEntity[]>;
 | 
				
			||||||
  getByChecksum(userId: string, checksum: Buffer): Promise<AssetEntity | null>;
 | 
					  getByChecksum(userId: string, checksum: Buffer): Promise<AssetEntity | null>;
 | 
				
			||||||
  getByAlbumId(pagination: PaginationOptions, albumId: string): Paginated<AssetEntity>;
 | 
					  getByAlbumId(pagination: PaginationOptions, albumId: string): Paginated<AssetEntity>;
 | 
				
			||||||
 | 
				
			|||||||
@ -104,10 +104,9 @@ export class AssetRepository implements IAssetRepository {
 | 
				
			|||||||
      .getMany();
 | 
					      .getMany();
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getByIds(ids: string[]): Promise<AssetEntity[]> {
 | 
					  getByIds(ids: string[], relations?: FindOptionsRelations<AssetEntity>): Promise<AssetEntity[]> {
 | 
				
			||||||
    return this.repository.find({
 | 
					    if (!relations) {
 | 
				
			||||||
      where: { id: In(ids) },
 | 
					      relations = {
 | 
				
			||||||
      relations: {
 | 
					 | 
				
			||||||
        exifInfo: true,
 | 
					        exifInfo: true,
 | 
				
			||||||
        smartInfo: true,
 | 
					        smartInfo: true,
 | 
				
			||||||
        tags: true,
 | 
					        tags: true,
 | 
				
			||||||
@ -115,7 +114,11 @@ export class AssetRepository implements IAssetRepository {
 | 
				
			|||||||
          person: true,
 | 
					          person: true,
 | 
				
			||||||
        },
 | 
					        },
 | 
				
			||||||
        stack: true,
 | 
					        stack: true,
 | 
				
			||||||
      },
 | 
					      };
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    return this.repository.find({
 | 
				
			||||||
 | 
					      where: { id: In(ids) },
 | 
				
			||||||
 | 
					      relations,
 | 
				
			||||||
      withDeleted: true,
 | 
					      withDeleted: true,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user