feat(server): track metadata extracted at (#6352)

This commit is contained in:
Jason Rasmussen 2024-01-12 19:39:45 -05:00 committed by GitHub
parent 19e9908ee2
commit f4edb6c4bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 30 additions and 2 deletions

View File

@ -252,6 +252,11 @@ export class MetadataService {
fileCreatedAt: exifData.dateTimeOriginal ?? undefined,
});
await this.assetRepository.upsertJobStatus({
assetId: asset.id,
metadataExtractedAt: new Date(),
});
return true;
}

View File

@ -12,4 +12,7 @@ export class AssetJobStatusEntity {
@Column({ type: 'timestamptz', nullable: true })
facesRecognizedAt!: Date | null;
@Column({ type: 'timestamptz', nullable: true })
metadataExtractedAt!: Date | null;
}

View File

@ -0,0 +1,19 @@
import { MigrationInterface, QueryRunner } from 'typeorm';
export class AddMetadataExtractedAt1705094221536 implements MigrationInterface {
name = 'AddMetadataExtractedAt1705094221536';
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "asset_job_status" ADD "metadataExtractedAt" TIMESTAMP WITH TIME ZONE`);
await queryRunner.query(`
UPDATE "asset_job_status"
SET "metadataExtractedAt" = NOW()
FROM "exif"
WHERE "exif"."assetId" = "asset_job_status"."assetId";
`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE "asset_job_status" DROP COLUMN "metadataExtractedAt"`);
}
}

View File

@ -474,11 +474,12 @@ export class AssetRepository implements IAssetRepository {
case WithoutProperty.EXIF:
relations = {
exifInfo: true,
jobStatus: true,
};
where = {
isVisible: true,
exifInfo: {
assetId: IsNull(),
jobStatus: {
metadataExtractedAt: IsNull(),
},
};
break;