From 0700b45f0625dc4e5189247d2838424474f4e260 Mon Sep 17 00:00:00 2001 From: Jonathan Jogenfors Date: Sun, 2 Feb 2025 12:55:44 +0100 Subject: [PATCH] don't search for null dates --- server/src/dtos/asset-response.dto.ts | 17 ++++++++--------- server/src/entities/asset.entity.ts | 6 +++--- server/src/interfaces/search.interface.ts | 3 --- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/server/src/dtos/asset-response.dto.ts b/server/src/dtos/asset-response.dto.ts index 5ac10c57a30b4..c4eb89af8164d 100644 --- a/server/src/dtos/asset-response.dto.ts +++ b/server/src/dtos/asset-response.dto.ts @@ -110,17 +110,16 @@ const hexOrBufferToBase64 = (encoded: string | Buffer) => { return encoded.toString('base64'); }; -export function mapAsset(entity: AssetEntity, options: AssetMapOptions = {}): AssetResponseDto { +export function mapAsset( + entity: AssetEntity & { localDateTime: NonNullable } & { + fileCreatedAt: NonNullable; + } & { + fileModifiedAt: NonNullable; + }, + options: AssetMapOptions = {}, +): AssetResponseDto { const { stripMetadata = false, withStack = false } = options; - if (!entity.localDateTime) { - throw new Error('Asset localDateTime is missing'); - } else if (!entity.fileCreatedAt) { - throw new Error('Asset fileCreatedAt is missing'); - } else if (!entity.fileModifiedAt) { - throw new Error('Asset fileModifiedAt is missing'); - } - if (stripMetadata) { const sanitizedAssetResponse: SanitizedAssetResponseDto = { id: entity.id, diff --git a/server/src/entities/asset.entity.ts b/server/src/entities/asset.entity.ts index 4ed74acec7d4e..54cb0d01cc988 100644 --- a/server/src/entities/asset.entity.ts +++ b/server/src/entities/asset.entity.ts @@ -400,7 +400,7 @@ export function searchAssetBuilder(kysely: Kysely, options: AssetSearchBuild .$if(!!options.withExif, withExifInner) .$if(!!(options.withFaces || options.withPeople || options.personIds), (qb) => qb.select(withFacesAndPeople)) .$if(!options.withDeleted, (qb) => qb.where('assets.deletedAt', 'is', null)) - .$if(!options.withNullFileModifiedAt, (qb) => qb.where('assets.fileModifiedAt', 'is not', null)) - .$if(!options.withNullFileCreatedAt, (qb) => qb.where('assets.fileCreatedAt', 'is not', null)) - .$if(!options.withNullLocalDateTime, (qb) => qb.where('assets.localDateTime', 'is not', null)); + .where('assets.fileCreatedAt', 'is not', null) + .where('assets.fileModifiedAt', 'is not', null) + .where('assets.localDateTime', 'is not', null); } diff --git a/server/src/interfaces/search.interface.ts b/server/src/interfaces/search.interface.ts index d6a109e89a7cb..bb76ff7b1fd04 100644 --- a/server/src/interfaces/search.interface.ts +++ b/server/src/interfaces/search.interface.ts @@ -63,9 +63,6 @@ export interface SearchStatusOptions { status?: AssetStatus; withArchived?: boolean; withDeleted?: boolean; - withNullLocalDateTime?: boolean; - withNullFileCreatedAt?: boolean; - withNullFileModifiedAt?: boolean; } export interface SearchOneToOneRelationOptions {