From 4cb779731445c90e6a663fb72cca10c624af58d1 Mon Sep 17 00:00:00 2001 From: smoh Date: Fri, 12 Dec 2025 10:19:41 +0900 Subject: [PATCH] =?UTF-8?q?DB=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=20=EB=B0=A9=EC=8B=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Workers/TriliumWorker.cs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Workers/TriliumWorker.cs b/Workers/TriliumWorker.cs index b681778..e61c6a1 100644 --- a/Workers/TriliumWorker.cs +++ b/Workers/TriliumWorker.cs @@ -11,13 +11,16 @@ public class TriliumWorker : BackgroundService { private readonly Serilog.ILogger _log; private readonly AppConfigs _config; + private readonly IServiceScopeFactory _scopeFactory; // Singleton services cannot directly inject Scoped services. private readonly TriliumService _triliumService; private readonly Channel _issueChannel; - public TriliumWorker(AppConfigs configs, TriliumService triliumService, Channel issueChannel) + public TriliumWorker(AppConfigs configs, IServiceScopeFactory serviceScopeFactory, + TriliumService triliumService, Channel issueChannel) { _log = Log.ForContext(); _config = configs; + _scopeFactory = serviceScopeFactory; _triliumService = triliumService; _issueChannel = issueChannel; } @@ -27,6 +30,15 @@ public class TriliumWorker : BackgroundService while (!stoppingToken.IsCancellationRequested) { _log.Debug("Worker running at: {time}", DateTimeOffset.Now); + + using var scope = _scopeFactory.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + var unpublishedIssues = await db.GetUnpublishedJiraIssuesAsync(stoppingToken); + if (unpublishedIssues != null) + { + // Publish or update Trilium notes + } + await Task.Delay(10 *1000, stoppingToken); } }