36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import { IndexingJob, IndexingJobDto, IndexingJobEntity } from '$lib/server/models/indexing-job.js';
|
|
|
|
export class IndexingJobMapper {
|
|
static fromEntity(entity: IndexingJobEntity): IndexingJob {
|
|
return new IndexingJob({
|
|
id: entity.id,
|
|
repositoryId: entity.repository_id,
|
|
versionId: entity.version_id,
|
|
status: entity.status,
|
|
progress: entity.progress,
|
|
totalFiles: entity.total_files,
|
|
processedFiles: entity.processed_files,
|
|
error: entity.error,
|
|
startedAt: entity.started_at != null ? new Date(entity.started_at * 1000) : null,
|
|
completedAt: entity.completed_at != null ? new Date(entity.completed_at * 1000) : null,
|
|
createdAt: new Date(entity.created_at * 1000)
|
|
});
|
|
}
|
|
|
|
static toDto(domain: IndexingJob): IndexingJobDto {
|
|
return new IndexingJobDto({
|
|
id: domain.id,
|
|
repositoryId: domain.repositoryId,
|
|
versionId: domain.versionId,
|
|
status: domain.status,
|
|
progress: domain.progress,
|
|
totalFiles: domain.totalFiles,
|
|
processedFiles: domain.processedFiles,
|
|
error: domain.error,
|
|
startedAt: domain.startedAt,
|
|
completedAt: domain.completedAt,
|
|
createdAt: domain.createdAt
|
|
});
|
|
}
|
|
}
|