refactor(server): change asset entity to date type (#2599)

* refactor(server): change asset entity to date type

* lower coverage threshold
This commit is contained in:
Michel Heusschen
2023-05-29 16:05:14 +02:00
committed by GitHub
parent caba462703
commit 94d0705607
18 changed files with 98 additions and 93 deletions

View File

@@ -37,8 +37,8 @@ const _getCreateAssetDto = (): CreateAssetDto => {
createAssetDto.deviceAssetId = 'deviceAssetId';
createAssetDto.deviceId = 'deviceId';
createAssetDto.assetType = AssetType.OTHER;
createAssetDto.fileCreatedAt = '2022-06-19T23:41:36.910Z';
createAssetDto.fileModifiedAt = '2022-06-19T23:41:36.910Z';
createAssetDto.fileCreatedAt = new Date('2022-06-19T23:41:36.910Z');
createAssetDto.fileModifiedAt = new Date('2022-06-19T23:41:36.910Z');
createAssetDto.isFavorite = false;
createAssetDto.isArchived = false;
createAssetDto.duration = '0:00:00.000000';
@@ -56,9 +56,9 @@ const _getAsset_1 = () => {
asset_1.type = AssetType.VIDEO;
asset_1.originalPath = 'fake_path/asset_1.jpeg';
asset_1.resizePath = '';
asset_1.fileModifiedAt = '2022-06-19T23:41:36.910Z';
asset_1.fileCreatedAt = '2022-06-19T23:41:36.910Z';
asset_1.updatedAt = '2022-06-19T23:41:36.910Z';
asset_1.fileModifiedAt = new Date('2022-06-19T23:41:36.910Z');
asset_1.fileCreatedAt = new Date('2022-06-19T23:41:36.910Z');
asset_1.updatedAt = new Date('2022-06-19T23:41:36.910Z');
asset_1.isFavorite = false;
asset_1.isArchived = false;
asset_1.mimeType = 'image/jpeg';
@@ -81,9 +81,9 @@ const _getAsset_2 = () => {
asset_2.type = AssetType.VIDEO;
asset_2.originalPath = 'fake_path/asset_2.jpeg';
asset_2.resizePath = '';
asset_2.fileModifiedAt = '2022-06-19T23:41:36.910Z';
asset_2.fileCreatedAt = '2022-06-19T23:41:36.910Z';
asset_2.updatedAt = '2022-06-19T23:41:36.910Z';
asset_2.fileModifiedAt = new Date('2022-06-19T23:41:36.910Z');
asset_2.fileCreatedAt = new Date('2022-06-19T23:41:36.910Z');
asset_2.updatedAt = new Date('2022-06-19T23:41:36.910Z');
asset_2.isFavorite = false;
asset_2.isArchived = false;
asset_2.mimeType = 'image/jpeg';

View File

@@ -16,10 +16,10 @@ export class CreateAssetDto {
assetType!: AssetType;
@IsNotEmpty()
fileCreatedAt!: string;
fileCreatedAt!: Date;
@IsNotEmpty()
fileModifiedAt!: string;
fileModifiedAt!: Date;
@IsNotEmpty()
isFavorite!: boolean;

View File

@@ -214,7 +214,7 @@ export class MetadataExtractionProcessor {
}
await this.exifRepository.upsert(newExif, { conflictPaths: ['assetId'] });
await this.assetRepository.save({ id: asset.id, fileCreatedAt: fileCreatedAt?.toISOString() });
await this.assetRepository.save({ id: asset.id, fileCreatedAt: fileCreatedAt || undefined });
return true;
}
@@ -227,9 +227,9 @@ export class MetadataExtractionProcessor {
const videoTags = data.format.tags;
if (videoTags) {
if (videoTags['com.apple.quicktime.creationdate']) {
fileCreatedAt = String(videoTags['com.apple.quicktime.creationdate']);
fileCreatedAt = new Date(videoTags['com.apple.quicktime.creationdate']);
} else if (videoTags['creation_time']) {
fileCreatedAt = String(videoTags['creation_time']);
fileCreatedAt = new Date(videoTags['creation_time']);
}
}