From cda7c0fe4c1ad6473aac476e05981587ee42e3e3 Mon Sep 17 00:00:00 2001 From: Jamie Date: Sun, 26 Aug 2018 13:59:10 +0100 Subject: [PATCH] !wip availability done --- src/Ombi.DependencyInjection/IocExtensions.cs | 1 + .../Jobs/Lidarr/ILidarrAvailabilityChecker.cs | 9 +++++++++ src/Ombi.Schedule/Jobs/Lidarr/LidarrAlbumSync.cs | 10 +++++++++- .../Jobs/Lidarr/LidarrAvailabilityChecker.cs | 2 +- 4 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 src/Ombi.Schedule/Jobs/Lidarr/ILidarrAvailabilityChecker.cs diff --git a/src/Ombi.DependencyInjection/IocExtensions.cs b/src/Ombi.DependencyInjection/IocExtensions.cs index 52f3db919..c4b291936 100644 --- a/src/Ombi.DependencyInjection/IocExtensions.cs +++ b/src/Ombi.DependencyInjection/IocExtensions.cs @@ -189,6 +189,7 @@ namespace Ombi.DependencyInjection services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); } } } diff --git a/src/Ombi.Schedule/Jobs/Lidarr/ILidarrAvailabilityChecker.cs b/src/Ombi.Schedule/Jobs/Lidarr/ILidarrAvailabilityChecker.cs new file mode 100644 index 000000000..f0c679229 --- /dev/null +++ b/src/Ombi.Schedule/Jobs/Lidarr/ILidarrAvailabilityChecker.cs @@ -0,0 +1,9 @@ +using System.Threading.Tasks; + +namespace Ombi.Schedule.Jobs.Lidarr +{ + public interface ILidarrAvailabilityChecker + { + Task Start(); + } +} \ No newline at end of file diff --git a/src/Ombi.Schedule/Jobs/Lidarr/LidarrAlbumSync.cs b/src/Ombi.Schedule/Jobs/Lidarr/LidarrAlbumSync.cs index 2eae36206..9708df589 100644 --- a/src/Ombi.Schedule/Jobs/Lidarr/LidarrAlbumSync.cs +++ b/src/Ombi.Schedule/Jobs/Lidarr/LidarrAlbumSync.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; +using Hangfire; using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore.Internal; using Microsoft.Extensions.Logging; @@ -19,12 +20,15 @@ namespace Ombi.Schedule.Jobs.Lidarr { public class LidarrAlbumSync : ILidarrAlbumSync { - public LidarrAlbumSync(ISettingsService lidarr, ILidarrApi lidarrApi, ILogger log, IOmbiContext ctx) + public LidarrAlbumSync(ISettingsService lidarr, ILidarrApi lidarrApi, ILogger log, IOmbiContext ctx, + IBackgroundJobClient job, ILidarrAvailabilityChecker availability) { _lidarrSettings = lidarr; _lidarrApi = lidarrApi; _logger = log; _ctx = ctx; + _job = job; + _availability = availability; _lidarrSettings.ClearCache(); } @@ -32,6 +36,8 @@ namespace Ombi.Schedule.Jobs.Lidarr private readonly ILidarrApi _lidarrApi; private readonly ILogger _logger; private readonly IOmbiContext _ctx; + private readonly IBackgroundJobClient _job; + private readonly ILidarrAvailabilityChecker _availability; 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"); } + + _job.Enqueue(() => _availability.Start()); } } catch (Exception) diff --git a/src/Ombi.Schedule/Jobs/Lidarr/LidarrAvailabilityChecker.cs b/src/Ombi.Schedule/Jobs/Lidarr/LidarrAvailabilityChecker.cs index b40eda06b..d5ba14a6d 100644 --- a/src/Ombi.Schedule/Jobs/Lidarr/LidarrAvailabilityChecker.cs +++ b/src/Ombi.Schedule/Jobs/Lidarr/LidarrAvailabilityChecker.cs @@ -15,7 +15,7 @@ using Ombi.Store.Repository.Requests; namespace Ombi.Schedule.Jobs.Lidarr { - public class LidarrAvailabilityChecker + public class LidarrAvailabilityChecker : ILidarrAvailabilityChecker { public LidarrAvailabilityChecker(IMusicRequestRepository requests, IRepository albums, ILogger log, IBackgroundJobClient job, INotificationService notification)