0
Fork 0
mirror of https://github.com/immich-app/immich.git synced 2025-02-11 01:18:24 -05:00

don't search for null dates

This commit is contained in:
Jonathan Jogenfors 2025-02-02 12:55:44 +01:00
parent b632b84fc3
commit 0700b45f06
3 changed files with 11 additions and 15 deletions

View file

@ -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<AssetEntity['localDateTime']> } & {
fileCreatedAt: NonNullable<AssetEntity['fileCreatedAt']>;
} & {
fileModifiedAt: NonNullable<AssetEntity['fileModifiedAt']>;
},
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,

View file

@ -400,7 +400,7 @@ export function searchAssetBuilder(kysely: Kysely<DB>, 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);
}

View file

@ -63,9 +63,6 @@ export interface SearchStatusOptions {
status?: AssetStatus;
withArchived?: boolean;
withDeleted?: boolean;
withNullLocalDateTime?: boolean;
withNullFileCreatedAt?: boolean;
withNullFileModifiedAt?: boolean;
}
export interface SearchOneToOneRelationOptions {