This commit is contained in:
tidusjar 2017-02-08 21:13:07 +00:00
parent 2345c3ff61
commit ccfaa56eaf
2 changed files with 25 additions and 5 deletions

View file

@ -46,7 +46,7 @@ namespace Ombi.Core
{ {
Db = new DbConfiguration(new SqliteFactory()); Db = new DbConfiguration(new SqliteFactory());
var created = Db.CheckDb(); var created = Db.CheckDb();
TableCreation.CreateTables(Db.DbConnection()); Db.DbConnection().CreateTables();
if (created) if (created)
{ {
@ -55,7 +55,7 @@ namespace Ombi.Core
else else
{ {
// Shrink DB // 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 // 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 try
{ {
Task.Run(() => { CacheSonarrQualityProfiles(mc); }); Task.Run(() => { CacheSonarrQualityProfiles(mc); });
Task.Run(() => { CacheRadarrQualityProfiles(mc); });
Task.Run(() => { CacheCouchPotatoQualityProfiles(mc); }); Task.Run(() => { CacheCouchPotatoQualityProfiles(mc); });
// we don't need to cache sickrage profiles, those are static // we don't need to cache sickrage profiles, those are static
} }
@ -126,7 +127,6 @@ namespace Ombi.Core
{ {
try try
{ {
Log.Info("Executing GetSettings call to Sonarr for quality profiles");
var sonarrSettingsService = new SettingsServiceV2<SonarrSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), cacheProvider)); var sonarrSettingsService = new SettingsServiceV2<SonarrSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), cacheProvider));
var sonarrSettings = sonarrSettingsService.GetSettings(); var sonarrSettings = sonarrSettingsService.GetSettings();
if (sonarrSettings.Enabled) if (sonarrSettings.Enabled)
@ -144,11 +144,31 @@ namespace Ombi.Core
} }
} }
private void CacheRadarrQualityProfiles(ICacheProvider cacheProvider)
{
try
{
var radarrService = new SettingsServiceV2<RadarrSettings>(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) private void CacheCouchPotatoQualityProfiles(ICacheProvider cacheProvider)
{ {
try try
{ {
Log.Info("Executing GetSettings call to CouchPotato for quality profiles");
var cpSettingsService = new SettingsServiceV2<CouchPotatoSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), cacheProvider)); var cpSettingsService = new SettingsServiceV2<CouchPotatoSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), cacheProvider));
var cpSettings = cpSettingsService.GetSettings(); var cpSettings = cpSettingsService.GetSettings();
if (cpSettings.Enabled) if (cpSettings.Enabled)

View file

@ -193,7 +193,7 @@ namespace Ombi.UI.Modules
{ {
// Approve it // Approve it
request.Approved = true; 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 // Update the record
var inserted = await Service.UpdateRequestAsync(request); var inserted = await Service.UpdateRequestAsync(request);