feature: Prometheus Metrics, Supervisor Dashboard, and Promotion Retry Job

This commit is contained in:
voltsrage
2026-06-27 13:29:04 +08:00
parent e22d33b654
commit 04bdb7e85c
31 changed files with 4482 additions and 259 deletions
@@ -15,6 +15,7 @@ public class DigitizationBatchesController : ControllerBase
private readonly IBatchService _batches;
private readonly IDocumentStorageService _storage;
private readonly IPromotionService _promotion;
private readonly IBatchEventService _batchEventService;
private static readonly HashSet<string> _allowedMimeTypes = new()
{
@@ -22,13 +23,15 @@ public class DigitizationBatchesController : ControllerBase
};
public DigitizationBatchesController(
IBatchService batches,
IDocumentStorageService storage,
IPromotionService promotion)
IBatchService batches,
IDocumentStorageService storage,
IPromotionService promotion,
IBatchEventService batchEventService)
{
_batches = batches;
_storage = storage;
_promotion = promotion;
_batchEventService = batchEventService;
}
/// <summary>
@@ -142,4 +145,38 @@ public class DigitizationBatchesController : ControllerBase
var result = await _promotion.PromoteAsync(id, actorUserId);
return Ok(ApiResponse<PromotionResult>.Ok(result));
}
/// <summary>
/// Returns cursor-paginated audit trail events for a batch.
/// Events are ordered chronologically (oldest first).
/// Pass the "after" parameter with the cursor from the previous page to paginate.
/// </summary>
/// <param name="id">Batch ID.</param>
/// <param name="after">Cursor: ISO-8601 timestamp from the previous page's nextCursor field.</param>
/// <param name="pageSize">Number of events per page. Default 50, max 200.</param>
[HttpGet("{id:guid}/events")]
[Authorize(Roles = "ADMINISTRATOR,VERIFIER,CLINICAL_APPROVER")]
[ProducesResponseType(typeof(ApiResponse<CursorPagedResult<BatchEventResponse>>), StatusCodes.Status200OK)]
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status400BadRequest)]
[ProducesResponseType(typeof(ApiResponse<object>), StatusCodes.Status404NotFound)]
public async Task<IActionResult> GetEvents(
Guid id,
[FromQuery] string? after = null,
[FromQuery] int pageSize = 50)
{
DateTimeOffset? afterCursor = null;
if (!string.IsNullOrWhiteSpace(after))
{
if (!DateTimeOffset.TryParse(after, out var parsed))
return BadRequest(ApiResponse<object>.Fail(
400,
"Invalid cursor format. Expected ISO-8601 timestamp.",
"INVALID_CURSOR"));
afterCursor = parsed;
}
var result = await _batchEventService.GetEventsAsync(id, afterCursor, pageSize);
return Ok(ApiResponse<CursorPagedResult<BatchEventResponse>>.Ok(result));
}
}