mirror of
				https://github.com/immich-app/immich.git
				synced 2025-11-03 19:17:11 -05:00 
			
		
		
		
	perf(server): optimize mapAsset (#7331)
This commit is contained in:
		
							parent
							
								
									869e9f1399
								
							
						
					
					
						commit
						ec55acc98c
					
				@ -73,23 +73,21 @@ const peopleWithFaces = (faces: AssetFaceEntity[]): PersonWithFacesResponseDto[]
 | 
				
			|||||||
export function mapAsset(entity: AssetEntity, options: AssetMapOptions = {}): AssetResponseDto {
 | 
					export function mapAsset(entity: AssetEntity, options: AssetMapOptions = {}): AssetResponseDto {
 | 
				
			||||||
  const { stripMetadata = false, withStack = false } = options;
 | 
					  const { stripMetadata = false, withStack = false } = options;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  const sanitizedAssetResponse: SanitizedAssetResponseDto = {
 | 
					 | 
				
			||||||
    id: entity.id,
 | 
					 | 
				
			||||||
    type: entity.type,
 | 
					 | 
				
			||||||
    thumbhash: entity.thumbhash?.toString('base64') ?? null,
 | 
					 | 
				
			||||||
    localDateTime: entity.localDateTime,
 | 
					 | 
				
			||||||
    resized: !!entity.resizePath,
 | 
					 | 
				
			||||||
    duration: entity.duration ?? '0:00:00.00000',
 | 
					 | 
				
			||||||
    livePhotoVideoId: entity.livePhotoVideoId,
 | 
					 | 
				
			||||||
    hasMetadata: false,
 | 
					 | 
				
			||||||
  };
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  if (stripMetadata) {
 | 
					  if (stripMetadata) {
 | 
				
			||||||
 | 
					    const sanitizedAssetResponse: SanitizedAssetResponseDto = {
 | 
				
			||||||
 | 
					      id: entity.id,
 | 
				
			||||||
 | 
					      type: entity.type,
 | 
				
			||||||
 | 
					      thumbhash: entity.thumbhash?.toString('base64') ?? null,
 | 
				
			||||||
 | 
					      localDateTime: entity.localDateTime,
 | 
				
			||||||
 | 
					      resized: !!entity.resizePath,
 | 
				
			||||||
 | 
					      duration: entity.duration ?? '0:00:00.00000',
 | 
				
			||||||
 | 
					      livePhotoVideoId: entity.livePhotoVideoId,
 | 
				
			||||||
 | 
					      hasMetadata: false,
 | 
				
			||||||
 | 
					    };
 | 
				
			||||||
    return sanitizedAssetResponse as AssetResponseDto;
 | 
					    return sanitizedAssetResponse as AssetResponseDto;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return {
 | 
					  return {
 | 
				
			||||||
    ...sanitizedAssetResponse,
 | 
					 | 
				
			||||||
    id: entity.id,
 | 
					    id: entity.id,
 | 
				
			||||||
    deviceAssetId: entity.deviceAssetId,
 | 
					    deviceAssetId: entity.deviceAssetId,
 | 
				
			||||||
    ownerId: entity.ownerId,
 | 
					    ownerId: entity.ownerId,
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user