[FA-misc] Mass transit overhaul, needs testing and review

This commit is contained in:
gamer147
2026-01-21 23:16:31 -05:00
parent 055ef33666
commit f88f340d0a
97 changed files with 1150 additions and 858 deletions

View File

@@ -0,0 +1,15 @@
using HotChocolate;
using HotChocolate.Authorization;
namespace FictionArchive.Service.ReportingService.GraphQL;
public class Mutation
{
/// <summary>
/// Placeholder mutation for GraphQL schema requirements.
/// The ReportingService is primarily read-only, consuming events from other services.
/// </summary>
[Authorize(Roles = ["admin"])]
[GraphQLDescription("Placeholder mutation. ReportingService is primarily read-only.")]
public bool Ping() => true;
}

View File

@@ -0,0 +1,52 @@
using System.Text.Json;
using FictionArchive.Service.ReportingService.Models.Database;
using FictionArchive.Service.ReportingService.Models.DTOs;
using FictionArchive.Service.ReportingService.Services;
using HotChocolate;
using HotChocolate.Data;
using Microsoft.EntityFrameworkCore;
namespace FictionArchive.Service.ReportingService.GraphQL;
public class Query
{
[UseProjection]
[UseFiltering]
[UseSorting]
[GraphQLName("reportingJobs")]
public IQueryable<Job> GetReportingJobs(ReportingServiceDbContext dbContext)
=> dbContext.Jobs.Include(j => j.History);
[GraphQLName("reportingJob")]
public async Task<JobDto?> GetReportingJob(Guid id, ReportingServiceDbContext dbContext)
{
var job = await dbContext.Jobs
.Include(j => j.History.OrderBy(h => h.Timestamp))
.FirstOrDefaultAsync(j => j.Id == id);
if (job == null) return null;
return new JobDto
{
Id = job.Id,
JobType = job.JobType,
Status = job.Status,
CurrentStep = job.CurrentStep,
ErrorMessage = job.ErrorMessage,
Metadata = job.Metadata != null
? JsonSerializer.Deserialize<Dictionary<string, object>>(job.Metadata.RootElement.GetRawText())
: null,
History = job.History.Select(h => new JobHistoryEntryDto
{
FromState = h.FromState,
ToState = h.ToState,
Message = h.Message,
Error = h.Error,
Timestamp = h.Timestamp
}).ToList(),
CreatedTime = job.CreatedTime,
UpdatedTime = job.UpdatedTime,
CompletedTime = job.CompletedTime
};
}
}