39 lines
1.4 KiB
C#
39 lines
1.4 KiB
C#
using Butter.Dtos.Jobs;
|
|
using Lactose.Jobs;
|
|
|
|
namespace Lactose.Mapper;
|
|
|
|
/// <summary>
|
|
/// Provides mapping methods for converting Job objects to DTOs.
|
|
/// </summary>
|
|
public static class JobMapper {
|
|
/// <summary>
|
|
/// Maps a Job to a JobStatusDto.
|
|
/// </summary>
|
|
/// <param name="job">The job to map.</param>
|
|
/// <returns>A JobStatusDto representing the job.</returns>
|
|
public static JobStatusDto ToJobStatusDto(this Job job) => new JobStatusDto() {
|
|
Id = job.Id,
|
|
ParentJobId = job.ParentJobId,
|
|
Name = job.Name,
|
|
Status = job.JobStatus.Status,
|
|
Progress = job.JobStatus.Progress,
|
|
Message = job.JobStatus.Message,
|
|
Created = job.JobStatus.Created,
|
|
Started = job.JobStatus.Started,
|
|
Finished = job.JobStatus.Finished,
|
|
|
|
JobType = job switch {
|
|
FileSystemCrawlJob => EJobType.FileSystemScan,
|
|
ThumbnailJob => EJobType.ThumbnailGeneration,
|
|
PreviewJob => EJobType.PreviewGeneration,
|
|
IntegrityCheckJob => EJobType.IntegrityCheck,
|
|
PHashJob => EJobType.PHashGeneration,
|
|
MetadataJob => EJobType.MetadataExtraction,
|
|
CreatePersonsJob => EJobType.CreatePersons,
|
|
CreateAlbumsJob => EJobType.CreateAlbums,
|
|
_ => throw new ArgumentOutOfRangeException(nameof(job))
|
|
}
|
|
};
|
|
}
|