mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-07-16 02:02:55 -07:00
cache injection, error handling and logging on startup, etc
This commit is contained in:
parent
2ddb949178
commit
7593d3a7e9
6 changed files with 179 additions and 144 deletions
|
@ -121,30 +121,45 @@ namespace PlexRequests.Core
|
|||
|
||||
private async void CacheSonarrQualityProfiles(MemoryCacheProvider cacheProvider)
|
||||
{
|
||||
var sonarrSettingsService = new SettingsServiceV2<SonarrSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
|
||||
var sonarrSettings = sonarrSettingsService.GetSettings();
|
||||
if (sonarrSettings.Enabled) {
|
||||
cacheProvider.GetOrSet(CacheKeys.SonarrQualityProfiles, () =>
|
||||
try
|
||||
{
|
||||
Log.Info("Executing GetSettings call to Sonarr for quality profiles");
|
||||
var sonarrSettingsService = new SettingsServiceV2<SonarrSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
|
||||
var sonarrSettings = sonarrSettingsService.GetSettings();
|
||||
if (sonarrSettings.Enabled)
|
||||
{
|
||||
Log.Info("Begin executing GetProfiles call to Sonarr for quality profiles");
|
||||
SonarrApi sonarrApi = new SonarrApi();
|
||||
return sonarrApi.GetProfiles(sonarrSettings.ApiKey, sonarrSettings.FullUri);
|
||||
|
||||
});
|
||||
var profiles = sonarrApi.GetProfiles(sonarrSettings.ApiKey, sonarrSettings.FullUri);
|
||||
cacheProvider.Set(CacheKeys.SonarrQualityProfiles, profiles);
|
||||
Log.Info("Finished executing GetProfiles call to Sonarr for quality profiles");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("Failed to cache Sonarr quality profiles!", ex);
|
||||
}
|
||||
}
|
||||
|
||||
private async void CacheCouchPotatoQualityProfiles(MemoryCacheProvider cacheProvider)
|
||||
{
|
||||
var cpSettingsService = new SettingsServiceV2<CouchPotatoSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
|
||||
var cpSettings = cpSettingsService.GetSettings();
|
||||
if (cpSettings.Enabled)
|
||||
try
|
||||
{
|
||||
cacheProvider.GetOrSet(CacheKeys.CouchPotatoQualityProfiles, () =>
|
||||
Log.Info("Executing GetSettings call to CouchPotato for quality profiles");
|
||||
var cpSettingsService = new SettingsServiceV2<CouchPotatoSettings>(new SettingsJsonRepository(new DbConfiguration(new SqliteFactory()), new MemoryCacheProvider()));
|
||||
var cpSettings = cpSettingsService.GetSettings();
|
||||
if (cpSettings.Enabled)
|
||||
{
|
||||
Log.Info("Begin executing GetProfiles call to CouchPotato for quality profiles");
|
||||
CouchPotatoApi cpApi = new CouchPotatoApi();
|
||||
return cpApi.GetProfiles(cpSettings.FullUri, cpSettings.ApiKey);
|
||||
|
||||
});
|
||||
var profiles = cpApi.GetProfiles(cpSettings.FullUri, cpSettings.ApiKey);
|
||||
cacheProvider.Set(CacheKeys.CouchPotatoQualityProfiles, profiles);
|
||||
Log.Info("Finished executing GetProfiles call to CouchPotato for quality profiles");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error("Failed to cache CouchPotato quality profiles!", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue