feat(daily-prep): add RunDailyPrepNow hub method and expose DailyPrepMaxTasks

This commit is contained in:
mika kuns
2026-06-03 16:30:23 +02:00
parent 20b3a29d08
commit 2d00160283
8 changed files with 32 additions and 6 deletions

View File

@@ -31,7 +31,8 @@ public record AppSettingsDto(
bool WorktreeAutoCleanupEnabled,
int WorktreeAutoCleanupDays,
string? ReportExcludedPaths,
int StandupWeekday);
int StandupWeekday,
int DailyPrepMaxTasks);
public record WorktreeCleanupDto(int Removed);
public record WorktreeResetDto(int Removed, int TasksAffected, bool Blocked, int RunningTasks);
@@ -79,6 +80,7 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
private readonly PlanningMergeOrchestrator _planningMergeOrchestrator;
private readonly PlanningChainCoordinator _planningChain;
private readonly IPrimeScheduleSignal _primeSignal;
private readonly IPrimeRunner _primeRunner;
private readonly ITaskStateService _state;
private readonly IWeekReportService _report;
@@ -98,6 +100,7 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
PlanningMergeOrchestrator planningMergeOrchestrator,
PlanningChainCoordinator planningChain,
IPrimeScheduleSignal primeSignal,
IPrimeRunner primeRunner,
ITaskStateService state,
IWeekReportService report)
{
@@ -116,6 +119,7 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
_planningMergeOrchestrator = planningMergeOrchestrator;
_planningChain = planningChain;
_primeSignal = primeSignal;
_primeRunner = primeRunner;
_state = state;
_report = report;
}
@@ -217,7 +221,8 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
row.WorktreeAutoCleanupEnabled,
row.WorktreeAutoCleanupDays,
row.ReportExcludedPaths,
row.StandupWeekday);
row.StandupWeekday,
row.DailyPrepMaxTasks);
}
public async Task UpdateAppSettings(AppSettingsDto dto)
@@ -238,6 +243,7 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
WorktreeAutoCleanupDays = dto.WorktreeAutoCleanupDays,
ReportExcludedPaths = dto.ReportExcludedPaths,
StandupWeekday = dto.StandupWeekday is >= 0 and <= 6 ? dto.StandupWeekday : (int)DayOfWeek.Wednesday,
DailyPrepMaxTasks = dto.DailyPrepMaxTasks,
});
}
@@ -533,6 +539,15 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
_primeSignal.Signal();
}
public async Task<bool> RunDailyPrepNow()
{
var schedule = new PrimeScheduleDto(Guid.Empty, 0, TimeSpan.Zero, true, null, null);
var firedAt = DateTimeOffset.Now;
var outcome = await _primeRunner.FireAsync(schedule, Context.ConnectionAborted);
await _broadcaster.PrimeFired(Guid.Empty, outcome.Success, outcome.Message, firedAt);
return outcome.Success;
}
private static DateOnly Day(string iso) => DateOnly.ParseExact(iso, "yyyy-MM-dd", CultureInfo.InvariantCulture);
public Task<string?> GetWeekReport(string startIso, string endIso) =>