|
|
@@ -40,7 +40,7 @@ public class S8ActiveFlowWatchService : ITransient
|
|
|
_logger = logger;
|
|
|
}
|
|
|
|
|
|
- public async Task<int> ScanAsync(CancellationToken cancellationToken = default)
|
|
|
+ public async Task<int> ScanAsync(long tenantId, long factoryId, CancellationToken cancellationToken = default)
|
|
|
{
|
|
|
if (!_options.Enabled)
|
|
|
return 0;
|
|
|
@@ -54,6 +54,7 @@ public class S8ActiveFlowWatchService : ITransient
|
|
|
|
|
|
var staleExceptions = await _exceptionRep.AsQueryable()
|
|
|
.Where(x => !x.IsDeleted && x.ActiveFlowInstanceId.HasValue &&
|
|
|
+ x.TenantId == tenantId && x.FactoryId == factoryId &&
|
|
|
SqlFunc.IsNull(x.UpdatedAt, x.CreatedAt) < staleBefore)
|
|
|
.OrderBy(x => x.UpdatedAt, OrderByType.Asc)
|
|
|
.OrderBy(x => x.Id, OrderByType.Asc)
|
|
|
@@ -65,7 +66,8 @@ public class S8ActiveFlowWatchService : ITransient
|
|
|
|
|
|
var exceptionIds = staleExceptions.Select(x => x.Id).ToHashSet();
|
|
|
var recentAlertLogs = await _notificationLogRep.AsQueryable()
|
|
|
- .Where(x => x.Channel == AlertChannel && x.CreatedAt >= alertedAfter && x.ExceptionId != null)
|
|
|
+ .Where(x => x.TenantId == tenantId && x.FactoryId == factoryId &&
|
|
|
+ x.Channel == AlertChannel && x.CreatedAt >= alertedAfter && x.ExceptionId != null)
|
|
|
.ToListAsync();
|
|
|
|
|
|
var alertedIds = recentAlertLogs
|