!wip availability done

pull/2478/head
Jamie 6 years ago
parent 82d610e235
commit cda7c0fe4c

@ -189,6 +189,7 @@ namespace Ombi.DependencyInjection
services.AddTransient<IPlexRecentlyAddedSync, PlexRecentlyAddedSync>(); services.AddTransient<IPlexRecentlyAddedSync, PlexRecentlyAddedSync>();
services.AddTransient<ILidarrAlbumSync, LidarrAlbumSync>(); services.AddTransient<ILidarrAlbumSync, LidarrAlbumSync>();
services.AddTransient<ILidarrArtistSync, LidarrArtistSync>(); services.AddTransient<ILidarrArtistSync, LidarrArtistSync>();
services.AddTransient<ILidarrAvailabilityChecker, LidarrAvailabilityChecker>();
} }
} }
} }

@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace Ombi.Schedule.Jobs.Lidarr
{
public interface ILidarrAvailabilityChecker
{
Task Start();
}
}

@ -2,6 +2,7 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
using Hangfire;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Internal; using Microsoft.EntityFrameworkCore.Internal;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -19,12 +20,15 @@ namespace Ombi.Schedule.Jobs.Lidarr
{ {
public class LidarrAlbumSync : ILidarrAlbumSync public class LidarrAlbumSync : ILidarrAlbumSync
{ {
public LidarrAlbumSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrAlbumSync> log, IOmbiContext ctx) public LidarrAlbumSync(ISettingsService<LidarrSettings> lidarr, ILidarrApi lidarrApi, ILogger<LidarrAlbumSync> log, IOmbiContext ctx,
IBackgroundJobClient job, ILidarrAvailabilityChecker availability)
{ {
_lidarrSettings = lidarr; _lidarrSettings = lidarr;
_lidarrApi = lidarrApi; _lidarrApi = lidarrApi;
_logger = log; _logger = log;
_ctx = ctx; _ctx = ctx;
_job = job;
_availability = availability;
_lidarrSettings.ClearCache(); _lidarrSettings.ClearCache();
} }
@ -32,6 +36,8 @@ namespace Ombi.Schedule.Jobs.Lidarr
private readonly ILidarrApi _lidarrApi; private readonly ILidarrApi _lidarrApi;
private readonly ILogger _logger; private readonly ILogger _logger;
private readonly IOmbiContext _ctx; private readonly IOmbiContext _ctx;
private readonly IBackgroundJobClient _job;
private readonly ILidarrAvailabilityChecker _availability;
public async Task CacheContent() public async Task CacheContent()
{ {
@ -74,6 +80,8 @@ namespace Ombi.Schedule.Jobs.Lidarr
{ {
_logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Lidarr Album"); _logger.LogError(LoggingEvents.Cacher, ex, "Failed caching queued items from Lidarr Album");
} }
_job.Enqueue(() => _availability.Start());
} }
} }
catch (Exception) catch (Exception)

@ -15,7 +15,7 @@ using Ombi.Store.Repository.Requests;
namespace Ombi.Schedule.Jobs.Lidarr namespace Ombi.Schedule.Jobs.Lidarr
{ {
public class LidarrAvailabilityChecker public class LidarrAvailabilityChecker : ILidarrAvailabilityChecker
{ {
public LidarrAvailabilityChecker(IMusicRequestRepository requests, IRepository<LidarrAlbumCache> albums, ILogger<LidarrAvailabilityChecker> log, public LidarrAvailabilityChecker(IMusicRequestRepository requests, IRepository<LidarrAlbumCache> albums, ILogger<LidarrAvailabilityChecker> log,
IBackgroundJobClient job, INotificationService notification) IBackgroundJobClient job, INotificationService notification)

Loading…
Cancel
Save