feat(hub): add RunTicketImportNow and ticket fallback list endpoints

This commit is contained in:
mika kuns
2026-10-01 08:41:12 +02:00
parent 915f2c8352
commit 9fc2e26edb
3 changed files with 72 additions and 7 deletions
+21 -6
View File
@@ -1028,11 +1028,15 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
return Task.CompletedTask;
}
public async Task<bool> RunDailyPrepNow()
public Task<bool> RunDailyPrepNow() => RunPrimeNowAsync(ClaudeDo.Data.Models.PrimeActionKind.FillMyDay);
/// <summary>The "Tickets + plan day" button: ticket import, then FillMyDay, through the same Prime gate.</summary>
public Task<bool> RunTicketImportNow() => RunPrimeNowAsync(ClaudeDo.Data.Models.PrimeActionKind.ImportTickets);
// A button means its own kind no matter how the schedules are configured — hence a synthetic schedule.
private async Task<bool> RunPrimeNowAsync(ClaudeDo.Data.Models.PrimeActionKind kind)
{
var schedule = new PrimeScheduleDto(
Guid.Empty, 0, TimeSpan.Zero, true, null, null,
ClaudeDo.Data.Models.PrimeActionKind.FillMyDay);
var schedule = new PrimeScheduleDto(Guid.Empty, 0, TimeSpan.Zero, true, null, null, kind);
var firedAt = DateTimeOffset.Now;
var outcome = await _primeRunner.FireAsync(schedule, Context.ConnectionAborted);
await _broadcaster.PrimeFired(Guid.Empty, outcome.Success, outcome.Message, firedAt);
@@ -1363,8 +1367,19 @@ public sealed class WorkerHub : Microsoft.AspNetCore.SignalR.Hub
// Liefert die EFFEKTIVE Base-URL (inkl. ergänztem Schema), nicht den rohen Feldwert: sonst
// sieht der Nutzer im Tab weiter "host.local", während der Client "http://host.local" ruft.
public TicketSettingsDto GetTicketSettings()
=> new(_ticketConfig.BaseUrl, _ticketConfig.Token is not null);
public async Task<TicketSettingsDto> GetTicketSettings()
{
using var ctx = _dbFactory.CreateDbContext();
var settings = await new AppSettingsRepository(ctx).GetAsync(Context.ConnectionAborted);
return new TicketSettingsDto(_ticketConfig.BaseUrl, _ticketConfig.Token is not null, settings.TicketFallbackListId);
}
/// <summary>Sets the list that import_ticket uses when Claude passes no list; null clears it.</summary>
public async Task SetTicketFallbackList(string? listId)
{
using var ctx = _dbFactory.CreateDbContext();
await new AppSettingsRepository(ctx).SetTicketFallbackListIdAsync(listId, Context.ConnectionAborted);
}
public void SetTicketApiBaseUrl(string? baseUrl)
{