using System.ComponentModel.DataAnnotations; using System.Text.Json; namespace ScrapperAPI.Dtos; public sealed class StartExtractionRequest { [Required] public int SessionId { get; set; } [Required] public long ModelId { get; set; } public bool OnlyDone { get; set; } public StartExtractionRequest() { } public StartExtractionRequest(int sessionId, long modelId, bool onlyDone = true) { SessionId = sessionId; ModelId = modelId; OnlyDone = onlyDone; } } public sealed class BulkStartExtractionRequest { [Required] public long ModelId { get; set; } /// /// Se vazio/nulo, roda para todas as sessions existentes. /// public int[]? SessionIds { get; set; } public bool OnlyDone { get; set; } public BulkStartExtractionRequest() { } public BulkStartExtractionRequest(long modelId, int[]? sessionIds = null, bool onlyDone = true) { ModelId = modelId; SessionIds = sessionIds; OnlyDone = onlyDone; } } public sealed class CreateExtractionRunDto { public long ModelId { get; set; } public int SessionId { get; set; } public CreateExtractionRunDto() { } public CreateExtractionRunDto(long modelId, int sessionId) { ModelId = modelId; SessionId = sessionId; } } public sealed class ExtractionRunRow { public long Id { get; set; } public long ModelId { get; set; } public int SessionId { get; set; } public short Status { get; set; } public DateTimeOffset CreatedAt { get; set; } public DateTimeOffset? StartedAt { get; set; } public DateTimeOffset? FinishedAt { get; set; } public int Total { get; set; } public int Succeeded { get; set; } public int Failed { get; set; } public string? Error { get; set; } public ExtractionRunRow() { } public ExtractionRunRow(long id, long modelId, int sessionId, short status, DateTimeOffset createdAt, DateTimeOffset? startedAt, DateTimeOffset? finishedAt, int total, int succeeded, int failed, string? error) { Id = id; ModelId = modelId; SessionId = sessionId; Status = status; CreatedAt = createdAt; StartedAt = startedAt; FinishedAt = finishedAt; Total = total; Succeeded = succeeded; Failed = failed; Error = error; } } public sealed class ExtractionRuntimeStatus { public long RunId { get; set; } public bool IsRunning { get; set; } public int Processed { get; set; } public int Total { get; set; } public int Succeeded { get; set; } public int Failed { get; set; } public int? CurrentQueueId { get; set; } public ExtractionRuntimeStatus() { } public ExtractionRuntimeStatus(long runId, bool isRunning, int processed, int total, int succeeded, int failed, int? currentQueueId) { RunId = runId; IsRunning = isRunning; Processed = processed; Total = total; Succeeded = succeeded; Failed = failed; CurrentQueueId = currentQueueId; } } public sealed class UpsertExtractedDataDto { public long RunId { get; set; } public long ModelId { get; set; } public int SessionId { get; set; } public int QueueId { get; set; } public JsonDocument ExtractedJson { get; set; } public bool Success { get; set; } public string? Error { get; set; } public UpsertExtractedDataDto() { } public UpsertExtractedDataDto(long runId, long modelId, int sessionId, int queueId, JsonDocument extractedJson, bool success, string? error) { RunId = runId; ModelId = modelId; SessionId = sessionId; QueueId = queueId; ExtractedJson = extractedJson; Success = success; Error = error; } } public sealed class ExtractedDataRow { public long Id { get; set; } public long RunId { get; set; } public long ModelId { get; set; } public int SessionId { get; set; } public int QueueId { get; set; } public JsonDocument ExtractedJson { get; set; } public bool Success { get; set; } public string? Error { get; set; } public DateTimeOffset ExtractedAt { get; set; } public ExtractedDataRow() { } public ExtractedDataRow(long id, long runId, long modelId, int sessionId, int queueId, JsonDocument extractedJson, bool success, string? error, DateTimeOffset extractedAt) { Id = id; RunId = runId; ModelId = modelId; SessionId = sessionId; QueueId = queueId; ExtractedJson = extractedJson; Success = success; Error = error; ExtractedAt = extractedAt; } }