Стримить прогресс пакетной переклассификации
CardReclassifier отдаёт IProgress-отчёты, эндпоинт публикует SSE cards_reclassified {progress:true,...} каждые 5 карточек и финальное событие; фронт показывает done/total и перечитывает доску только по финалу. Закрывает BL-RECLASS-SSE.
This commit is contained in:
@@ -324,7 +324,23 @@ public static class CardsEndpoints
|
||||
}
|
||||
|
||||
CardReclassifier reclassifier = context.RequestServices.GetRequiredService<CardReclassifier>();
|
||||
ReclassifyResultDto result = await reclassifier.ReclassifyInboxAsync(body?.Ids, ct);
|
||||
SseBroker broker = context.RequestServices.GetRequiredService<SseBroker>();
|
||||
Guid tenantId = context.GetCurrentUser()!.TenantId;
|
||||
// Синхронный IProgress: события прогресса уходят в SSE в порядке прохода, до финального события.
|
||||
var progress = new InlineProgress<ReclassifyProgressDto>(value => broker.Publish(
|
||||
tenantId,
|
||||
ReclassifiedEventType,
|
||||
new
|
||||
{
|
||||
progress = true,
|
||||
done = value.Done,
|
||||
total = value.Total,
|
||||
moved = value.Moved,
|
||||
kept = value.Kept,
|
||||
trashed = value.Trashed,
|
||||
skipped = value.Skipped,
|
||||
}));
|
||||
ReclassifyResultDto result = await reclassifier.ReclassifyInboxAsync(body?.Ids, ct, progress);
|
||||
await AppendReclassifyAuditAsync(context, result, ct);
|
||||
PublishReclassified(context, result);
|
||||
return Results.Ok(ToReclassifyWire(result));
|
||||
@@ -386,7 +402,7 @@ public static class CardsEndpoints
|
||||
broker.Publish(
|
||||
context.GetCurrentUser()!.TenantId,
|
||||
ReclassifiedEventType,
|
||||
new { reclassified = result.Reclassified, moved = result.Moved });
|
||||
new { reclassified = result.Reclassified, moved = result.Moved, progress = false });
|
||||
}
|
||||
|
||||
// Аудит переклассификации: пишется только когда проход реально что-то изменил.
|
||||
|
||||
Reference in New Issue
Block a user