72 lines
2.3 KiB
C#
72 lines
2.3 KiB
C#
using FictionArchive.Service.ReportingService.Models.DTOs;
|
|
using FictionArchive.Service.ReportingService.Services;
|
|
using HotChocolate.Authorization;
|
|
using HotChocolate.Data;
|
|
|
|
namespace FictionArchive.Service.ReportingService.GraphQL;
|
|
|
|
public class Query
|
|
{
|
|
[Authorize]
|
|
//[UseProjection]
|
|
[UseFirstOrDefault]
|
|
public IQueryable<JobDto> GetJobById(
|
|
Guid jobId,
|
|
ReportingDbContext db)
|
|
=> db.Jobs.Where(j => j.Id == jobId).Select(j => new JobDto
|
|
{
|
|
Id = j.Id,
|
|
CreatedTime = j.CreatedTime,
|
|
LastUpdatedTime = j.LastUpdatedTime,
|
|
ParentJobId = j.ParentJobId,
|
|
JobType = j.JobType,
|
|
DisplayName = j.DisplayName,
|
|
Status = j.Status,
|
|
ErrorMessage = j.ErrorMessage,
|
|
Metadata = j.Metadata,
|
|
ChildJobs = j.ChildJobs.Select(c => new JobDto
|
|
{
|
|
Id = c.Id,
|
|
CreatedTime = c.CreatedTime,
|
|
LastUpdatedTime = c.LastUpdatedTime,
|
|
ParentJobId = c.ParentJobId,
|
|
JobType = c.JobType,
|
|
DisplayName = c.DisplayName,
|
|
Status = c.Status,
|
|
ErrorMessage = c.ErrorMessage,
|
|
Metadata = c.Metadata
|
|
})
|
|
});
|
|
|
|
[Authorize]
|
|
[UsePaging]
|
|
//[UseProjection]
|
|
[UseFiltering]
|
|
[UseSorting]
|
|
public IQueryable<JobDto> GetJobs(ReportingDbContext db)
|
|
=> db.Jobs.Select(j => new JobDto
|
|
{
|
|
Id = j.Id,
|
|
CreatedTime = j.CreatedTime,
|
|
LastUpdatedTime = j.LastUpdatedTime,
|
|
ParentJobId = j.ParentJobId,
|
|
JobType = j.JobType,
|
|
DisplayName = j.DisplayName,
|
|
Status = j.Status,
|
|
ErrorMessage = j.ErrorMessage,
|
|
Metadata = j.Metadata,
|
|
ChildJobs = j.ChildJobs.Select(c => new JobDto
|
|
{
|
|
Id = c.Id,
|
|
CreatedTime = c.CreatedTime,
|
|
LastUpdatedTime = c.LastUpdatedTime,
|
|
ParentJobId = c.ParentJobId,
|
|
JobType = c.JobType,
|
|
DisplayName = c.DisplayName,
|
|
Status = c.Status,
|
|
ErrorMessage = c.ErrorMessage,
|
|
Metadata = c.Metadata
|
|
})
|
|
});
|
|
}
|