bug fixes and logging (#786)

This commit is contained in:
Jason Dove
2022-05-05 10:04:24 -05:00
committed by GitHub
parent 8542bc20b1
commit daf7114ce2
8 changed files with 52 additions and 22 deletions
@@ -0,0 +1,21 @@
using ErsatzTV.Application.Search;
using MediatR;
namespace ErsatzTV.Services.RunOnce;
public class RebuildSearchIndexService : IHostedService
{
private readonly IServiceScopeFactory _serviceScopeFactory;
public RebuildSearchIndexService(IServiceScopeFactory serviceScopeFactory) =>
_serviceScopeFactory = serviceScopeFactory;
public async Task StartAsync(CancellationToken cancellationToken)
{
using IServiceScope scope = _serviceScopeFactory.CreateScope();
IMediator mediator = scope.ServiceProvider.GetRequiredService<IMediator>();
await mediator.Send(new RebuildSearchIndex(), cancellationToken);
}
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
}
-5
View File
@@ -8,7 +8,6 @@ using ErsatzTV.Application.MediaCollections;
using ErsatzTV.Application.MediaSources;
using ErsatzTV.Application.Playouts;
using ErsatzTV.Application.Plex;
using ErsatzTV.Application.Search;
using ErsatzTV.Core.Domain;
using ErsatzTV.Core.Interfaces.Locking;
using ErsatzTV.Core.Scheduling;
@@ -93,7 +92,6 @@ public class SchedulerService : BackgroundService
try
{
await DeleteOrphanedArtwork(cancellationToken);
await RebuildSearchIndex(cancellationToken);
await BuildPlayouts(cancellationToken);
await ScanLocalMediaSources(cancellationToken);
await ScanPlexMediaSources(cancellationToken);
@@ -266,9 +264,6 @@ public class SchedulerService : BackgroundService
}
}
private ValueTask RebuildSearchIndex(CancellationToken cancellationToken) =>
_workerChannel.WriteAsync(new RebuildSearchIndex(), cancellationToken);
private ValueTask DeleteOrphanedArtwork(CancellationToken cancellationToken) =>
_workerChannel.WriteAsync(new DeleteOrphanedArtwork(), cancellationToken);
}