mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 17:43:12 +00:00
Introduce in-process WeekRolled job with idempotent ledger to increment carriedOver for the SHOC board, plus optional PastDue cache and admin reprocess endpoints while keeping isPastDue derived on-read.
48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using System.Diagnostics;
|
|
using Microsoft.Extensions.Logging;
|
|
using SeaHaven.DataServices.Interfaces;
|
|
using SeaHaven.Services.DTOs;
|
|
using SeaHaven.Services.Interfaces;
|
|
|
|
namespace SeaHaven.Services.Implementation
|
|
{
|
|
public class PastDueCacheService : IPastDueCacheService
|
|
{
|
|
private readonly IWorkOrderDomainJobDataService _dataService;
|
|
private readonly ILogger<PastDueCacheService> _logger;
|
|
|
|
public PastDueCacheService(
|
|
IWorkOrderDomainJobDataService dataService,
|
|
ILogger<PastDueCacheService> logger)
|
|
{
|
|
_dataService = dataService;
|
|
_logger = logger;
|
|
}
|
|
|
|
public async Task<PastDueCacheJobResult> RefreshAsync(CancellationToken cancellationToken = default)
|
|
{
|
|
var stopwatch = Stopwatch.StartNew();
|
|
var utcNow = DateTime.UtcNow;
|
|
|
|
_logger.LogInformation("PastDue cache refresh started at {UtcNow}", utcNow);
|
|
|
|
var refreshResult = await _dataService.RefreshPastDueFlagsAsync(utcNow, cancellationToken: cancellationToken);
|
|
|
|
stopwatch.Stop();
|
|
|
|
var result = new PastDueCacheJobResult
|
|
{
|
|
SetCount = refreshResult.SetCount,
|
|
ClearedCount = refreshResult.ClearedCount,
|
|
ExaminedCount = refreshResult.ExaminedCount,
|
|
DurationMs = stopwatch.ElapsedMilliseconds
|
|
};
|
|
|
|
_logger.LogInformation(
|
|
"PastDue cache refresh completed. Set={SetCount}, Cleared={ClearedCount}, Examined={ExaminedCount}, DurationMs={DurationMs}",
|
|
result.SetCount, result.ClearedCount, result.ExaminedCount, result.DurationMs);
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|