wip
This commit is contained in:
@@ -99,4 +99,7 @@ export class AllJobStatusResponseDto implements Record<QueueName, JobStatusDto>
|
||||
|
||||
@ApiProperty({ type: JobStatusDto })
|
||||
[QueueName.BACKUP_DATABASE]!: JobStatusDto;
|
||||
|
||||
@ApiProperty({ type: JobStatusDto })
|
||||
[QueueName.DATABASE_INTEGRITY_CHECK]!: JobStatusDto;
|
||||
}
|
||||
|
||||
@@ -251,6 +251,7 @@ export enum ManualJobName {
|
||||
MEMORY_CLEANUP = 'memory-cleanup',
|
||||
MEMORY_CREATE = 'memory-create',
|
||||
BACKUP_DATABASE = 'backup-database',
|
||||
INTEGRITY_DATABASE_CHECK = 'integrity-database-check',
|
||||
}
|
||||
|
||||
export enum AssetPathType {
|
||||
@@ -441,6 +442,7 @@ export enum QueueName {
|
||||
LIBRARY = 'library',
|
||||
NOTIFICATION = 'notifications',
|
||||
BACKUP_DATABASE = 'backupDatabase',
|
||||
DATABASE_INTEGRITY_CHECK = 'integrityDatabaseCheck',
|
||||
}
|
||||
|
||||
export enum JobName {
|
||||
@@ -532,6 +534,9 @@ export enum JobName {
|
||||
|
||||
// Version check
|
||||
VERSION_CHECK = 'version-check',
|
||||
|
||||
// Integrity
|
||||
DATABASE_INTEGRITY_CHECK = 'database-integrity-check',
|
||||
}
|
||||
|
||||
export enum JobCommand {
|
||||
|
||||
@@ -463,3 +463,12 @@ where
|
||||
and "libraryId" = $2::uuid
|
||||
and "isExternal" = $3
|
||||
)
|
||||
|
||||
-- AssetRepository.integrityCheckExif
|
||||
select
|
||||
"id"
|
||||
from
|
||||
"assets"
|
||||
left join "exif" on "assets"."id" = "exif"."assetId"
|
||||
where
|
||||
"exif"."assetId" is null
|
||||
|
||||
@@ -875,4 +875,16 @@ export class AssetRepository {
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
@GenerateSql()
|
||||
async integrityCheckExif(): Promise<string[]> {
|
||||
const result = await this.db
|
||||
.selectFrom('assets')
|
||||
.select('id')
|
||||
.leftJoin('exif', 'assets.id', 'exif.assetId')
|
||||
.where('exif.assetId', 'is', null)
|
||||
.execute();
|
||||
|
||||
return result.map((row) => row.id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import { CliService } from 'src/services/cli.service';
|
||||
import { DatabaseService } from 'src/services/database.service';
|
||||
import { DownloadService } from 'src/services/download.service';
|
||||
import { DuplicateService } from 'src/services/duplicate.service';
|
||||
import { IntegrityService } from 'src/services/integrity.service';
|
||||
import { JobService } from 'src/services/job.service';
|
||||
import { LibraryService } from 'src/services/library.service';
|
||||
import { MapService } from 'src/services/map.service';
|
||||
@@ -54,6 +55,7 @@ export const services = [
|
||||
DatabaseService,
|
||||
DownloadService,
|
||||
DuplicateService,
|
||||
IntegrityService,
|
||||
JobService,
|
||||
LibraryService,
|
||||
MapService,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Injectable } from '@nestjs/common';
|
||||
import { OnJob } from 'src/decorators';
|
||||
import { JobName, JobStatus, QueueName } from 'src/enum';
|
||||
import { BaseService } from 'src/services/base.service';
|
||||
|
||||
@Injectable()
|
||||
export class IntegrityService extends BaseService {
|
||||
@OnJob({ name: JobName.DATABASE_INTEGRITY_CHECK, queue: QueueName.DATABASE_INTEGRITY_CHECK })
|
||||
async handleDatabaseIntegrityCheck(): Promise<JobStatus> {
|
||||
console.log(JSON.stringify(await this.assetRepository.integrityCheckExif()));
|
||||
return JobStatus.SUCCESS;
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,10 @@ const asJobItem = (dto: JobCreateDto): JobItem => {
|
||||
return { name: JobName.BACKUP_DATABASE };
|
||||
}
|
||||
|
||||
case ManualJobName.INTEGRITY_DATABASE_CHECK: {
|
||||
return { name: JobName.DATABASE_INTEGRITY_CHECK };
|
||||
}
|
||||
|
||||
default: {
|
||||
throw new BadRequestException('Invalid job name');
|
||||
}
|
||||
@@ -228,6 +232,7 @@ export class JobService extends BaseService {
|
||||
QueueName.STORAGE_TEMPLATE_MIGRATION,
|
||||
QueueName.DUPLICATE_DETECTION,
|
||||
QueueName.BACKUP_DATABASE,
|
||||
QueueName.DATABASE_INTEGRITY_CHECK,
|
||||
].includes(name);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -164,6 +164,7 @@ export type ConcurrentQueueName = Exclude<
|
||||
| QueueName.FACIAL_RECOGNITION
|
||||
| QueueName.DUPLICATE_DETECTION
|
||||
| QueueName.BACKUP_DATABASE
|
||||
| QueueName.DATABASE_INTEGRITY_CHECK
|
||||
>;
|
||||
|
||||
export type Jobs = { [K in JobItem['name']]: (JobItem & { name: K })['data'] };
|
||||
@@ -363,9 +364,8 @@ export type JobItem =
|
||||
// Version check
|
||||
| { name: JobName.VERSION_CHECK; data: IBaseJob }
|
||||
|
||||
// Memories
|
||||
| { name: JobName.MEMORIES_CLEANUP; data?: IBaseJob }
|
||||
| { name: JobName.MEMORIES_CREATE; data?: IBaseJob };
|
||||
// Integrity
|
||||
| { name: JobName.DATABASE_INTEGRITY_CHECK; data?: IBaseJob };
|
||||
|
||||
export type VectorExtension = DatabaseExtension.VECTOR | DatabaseExtension.VECTORS;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user