fix(news): use CreateAsyncScope for Playwright service and gracefully handle DbUpdateException on duplicate URLs
This commit is contained in:
@@ -61,7 +61,7 @@ public class NewsScraperBackgroundService : BackgroundService
|
||||
{
|
||||
try
|
||||
{
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await using var scope = _scopeFactory.CreateAsyncScope();
|
||||
var settings = scope.ServiceProvider.GetRequiredService<ISettingsService>();
|
||||
bool enabled = await settings.GetSettingAsync(SettingKeys.EnableAutoScraping, stoppingToken);
|
||||
|
||||
@@ -82,7 +82,7 @@ public class NewsScraperBackgroundService : BackgroundService
|
||||
int intervalMinutes = 15;
|
||||
try
|
||||
{
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await using var scope = _scopeFactory.CreateAsyncScope();
|
||||
var settings = scope.ServiceProvider.GetRequiredService<ISettingsService>();
|
||||
intervalMinutes = await settings.GetSettingAsync(SettingKeys.ScrapeIntervalMinutes, stoppingToken);
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public class NewsScraperBackgroundService : BackgroundService
|
||||
|
||||
private async Task RunScrapingCycleAsync(CancellationToken stoppingToken)
|
||||
{
|
||||
using var scope = _scopeFactory.CreateScope();
|
||||
await using var scope = _scopeFactory.CreateAsyncScope();
|
||||
var dbService = scope.ServiceProvider.GetRequiredService<INewsDbService>();
|
||||
var discoveryService = scope.ServiceProvider.GetRequiredService<IArticleDiscoveryService>();
|
||||
var scraperService = scope.ServiceProvider.GetRequiredService<IPlaywrightScraperService>();
|
||||
|
||||
Reference in New Issue
Block a user