mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 15:23:12 +00:00
33 lines
1.2 KiB
C#
33 lines
1.2 KiB
C#
|
|
using Data.SeaHavenIndustries;
|
||
|
|
using Microsoft.EntityFrameworkCore;
|
||
|
|
using SeaHaven.DataServices.Interfaces;
|
||
|
|
|
||
|
|
namespace SeaHaven.DataServices.Implementation
|
||
|
|
{
|
||
|
|
public class WorkOrderOpsHealthDataService : IWorkOrderOpsHealthDataService
|
||
|
|
{
|
||
|
|
private readonly ApplicationDbContext _context;
|
||
|
|
|
||
|
|
public WorkOrderOpsHealthDataService(ApplicationDbContext context)
|
||
|
|
{
|
||
|
|
_context = context;
|
||
|
|
}
|
||
|
|
|
||
|
|
public Task<int> CountSyncRejectedSinceAsync(DateTime since, CancellationToken cancellationToken)
|
||
|
|
=> _context.WorkOrderAuditLogs
|
||
|
|
.CountAsync(l => l.Action == "SyncRejected" && l.CreatedAt >= since, cancellationToken);
|
||
|
|
|
||
|
|
public Task<int> CountFieldLocksAsync(CancellationToken cancellationToken)
|
||
|
|
=> _context.WorkOrderFieldLocks.CountAsync(cancellationToken);
|
||
|
|
|
||
|
|
public async Task<DateTime?> GetLastWeekRolledProcessedAtAsync(CancellationToken cancellationToken)
|
||
|
|
{
|
||
|
|
if (!await _context.WorkOrderWeekRolledLedgers.AnyAsync(cancellationToken))
|
||
|
|
return null;
|
||
|
|
|
||
|
|
return await _context.WorkOrderWeekRolledLedgers
|
||
|
|
.MaxAsync(l => (DateTime?)l.ProcessedAt, cancellationToken);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|