From ccfaa56eaf5f8e8446a693581339bc2f56ee6cbb Mon Sep 17 00:00:00 2001 From: tidusjar Date: Wed, 8 Feb 2017 21:13:07 +0000 Subject: [PATCH] #1049 --- Ombi.Core/Setup.cs | 28 ++++++++++++++++++++++++---- Ombi.UI/Modules/ApprovalModule.cs | 2 +- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/Ombi.Core/Setup.cs b/Ombi.Core/Setup.cs index f70749a40..1eb05837b 100644 --- a/Ombi.Core/Setup.cs +++ b/Ombi.Core/Setup.cs @@ -46,7 +46,7 @@ namespace Ombi.Core { Db = new DbConfiguration(new SqliteFactory()); var created = Db.CheckDb(); - TableCreation.CreateTables(Db.DbConnection()); + Db.DbConnection().CreateTables(); if (created) { @@ -55,7 +55,7 @@ namespace Ombi.Core else { // Shrink DB - TableCreation.Vacuum(Db.DbConnection()); + Db.DbConnection().Vacuum(); } // Add the new 'running' item into the scheduled jobs so we can check if the cachers are running @@ -113,6 +113,7 @@ namespace Ombi.Core try { Task.Run(() => { CacheSonarrQualityProfiles(mc); }); + Task.Run(() => { CacheRadarrQualityProfiles(mc); }); Task.Run(() => { CacheCouchPotatoQualityProfiles(mc); }); // we don't need to cache sickrage profiles, those are static } @@ -126,7 +127,6 @@ namespace Ombi.Core { try { - Log.Info("Executing GetSettings call to Sonarr for quality profiles"); var sonarrSettingsService = new SettingsServiceV2(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), cacheProvider)); var sonarrSettings = sonarrSettingsService.GetSettings(); if (sonarrSettings.Enabled) @@ -144,11 +144,31 @@ namespace Ombi.Core } } + private void CacheRadarrQualityProfiles(ICacheProvider cacheProvider) + { + try + { + var radarrService = new SettingsServiceV2(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), cacheProvider)); + var radarrSettings = radarrService.GetSettings(); + if (radarrSettings.Enabled) + { + Log.Info("Begin executing GetProfiles call to Radarr for quality profiles"); + RadarrApi radarrApi = new RadarrApi(); + var profiles = radarrApi.GetProfiles(radarrSettings.ApiKey, radarrSettings.FullUri); + cacheProvider.Set(CacheKeys.RadarrQualityProfiles, profiles); + Log.Info("Finished executing GetProfiles call to Radarr for quality profiles"); + } + } + catch (Exception ex) + { + Log.Error(ex, "Failed to cache Sonarr quality profiles!"); + } + } + private void CacheCouchPotatoQualityProfiles(ICacheProvider cacheProvider) { try { - Log.Info("Executing GetSettings call to CouchPotato for quality profiles"); var cpSettingsService = new SettingsServiceV2(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), cacheProvider)); var cpSettings = cpSettingsService.GetSettings(); if (cpSettings.Enabled) diff --git a/Ombi.UI/Modules/ApprovalModule.cs b/Ombi.UI/Modules/ApprovalModule.cs index 667b3e843..dd094b468 100644 --- a/Ombi.UI/Modules/ApprovalModule.cs +++ b/Ombi.UI/Modules/ApprovalModule.cs @@ -193,7 +193,7 @@ namespace Ombi.UI.Modules { // Approve it request.Approved = true; - Log.Warn("We approved movie: {0} but could not add it to CouchPotato/Watcher because it has not been setup", request.Title); + Log.Warn("We approved movie: {0} but could not add it to CouchPotato/Watcher/Radarr because it has not been setup", request.Title); // Update the record var inserted = await Service.UpdateRequestAsync(request);