Merge branch 'develop' of https://github.com/tidusjar/ombi into develop

pull/2754/head
TidusJar 6 years ago
commit c8df191e80

@ -1,5 +1,6 @@
# Changelog
## (unreleased)
### **New Features**
@ -40,6 +41,9 @@
- Added the ability to deny a request with a reason. [TidusJar]
## v3.0.4036 (2018-12-11)
- Update EmbyEpisodeSync.cs. [Jamie]
- Updated to .net core 2.2 and included a linux-arm64 build. [TidusJar]

@ -200,6 +200,7 @@ namespace Ombi.DependencyInjection
services.AddTransient<ILidarrAvailabilityChecker, LidarrAvailabilityChecker>();
services.AddTransient<IIssuesPurge, IssuesPurge>();
services.AddTransient<IResendFailedRequests, ResendFailedRequests>();
services.AddTransient<IMediaDatabaseRefresh, MediaDatabaseRefresh>();
}
}
}

@ -21,6 +21,7 @@ namespace Ombi.Helpers
public static EventId PlexContentCacher => new EventId(2008);
public static EventId SickRageCacher => new EventId(2009);
public static EventId LidarrArtistCache => new EventId(2010);
public static EventId MediaReferesh => new EventId(2011);
public static EventId MovieSender => new EventId(3000);

@ -7,6 +7,7 @@ using Ombi.Schedule.Jobs.Emby;
using Ombi.Schedule.Jobs.Lidarr;
using Ombi.Schedule.Jobs.Ombi;
using Ombi.Schedule.Jobs.Plex;
using Ombi.Schedule.Jobs.Plex.Interfaces;
using Ombi.Schedule.Jobs.Radarr;
using Ombi.Schedule.Jobs.SickRage;
using Ombi.Schedule.Jobs.Sonarr;
@ -21,7 +22,7 @@ namespace Ombi.Schedule
IEmbyUserImporter embyUserImporter, ISonarrSync cache, ICouchPotatoSync cpCache,
ISettingsService<JobSettings> jobsettings, ISickRageSync srSync, IRefreshMetadata refresh,
INewsletterJob newsletter, IPlexRecentlyAddedSync recentlyAddedPlex, ILidarrArtistSync artist,
IIssuesPurge purge, IResendFailedRequests resender)
IIssuesPurge purge, IResendFailedRequests resender, IMediaDatabaseRefresh dbRefresh)
{
_plexContentSync = plexContentSync;
_radarrSync = radarrSync;
@ -39,6 +40,7 @@ namespace Ombi.Schedule
_lidarrArtistSync = artist;
_issuesPurge = purge;
_resender = resender;
_mediaDatabaseRefresh = dbRefresh;
}
private readonly IPlexContentSync _plexContentSync;
@ -57,6 +59,7 @@ namespace Ombi.Schedule
private readonly ILidarrArtistSync _lidarrArtistSync;
private readonly IIssuesPurge _issuesPurge;
private readonly IResendFailedRequests _resender;
private readonly IMediaDatabaseRefresh _mediaDatabaseRefresh;
public void Setup()
{
@ -80,9 +83,9 @@ namespace Ombi.Schedule
RecurringJob.AddOrUpdate(() => _newsletter.Start(), JobSettingsHelper.Newsletter(s));
RecurringJob.AddOrUpdate(() => _newsletter.Start(), JobSettingsHelper.Newsletter(s));
RecurringJob.AddOrUpdate(() => _resender.Start(), JobSettingsHelper.ResendFailedRequests(s));
RecurringJob.AddOrUpdate(() => _mediaDatabaseRefresh.Start(), JobSettingsHelper.MediaDatabaseRefresh(s));
}
private bool _disposed;
protected virtual void Dispose(bool disposing)
{

@ -0,0 +1,9 @@
using System.Threading.Tasks;
namespace Ombi.Schedule.Jobs.Plex.Interfaces
{
public interface IMediaDatabaseRefresh : IBaseJob
{
Task Start();
}
}

@ -0,0 +1,120 @@
using System;
using System.Threading.Tasks;
using Hangfire;
using Microsoft.Extensions.Logging;
using Ombi.Api.Plex;
using Ombi.Core.Settings;
using Ombi.Core.Settings.Models.External;
using Ombi.Helpers;
using Ombi.Schedule.Jobs.Emby;
using Ombi.Schedule.Jobs.Plex.Interfaces;
using Ombi.Store.Repository;
namespace Ombi.Schedule.Jobs.Plex
{
public class MediaDatabaseRefresh : IMediaDatabaseRefresh
{
public MediaDatabaseRefresh(ISettingsService<PlexSettings> s, ILogger<MediaDatabaseRefresh> log, IPlexApi plexApi,
IPlexContentRepository plexRepo, IPlexContentSync c, IEmbyContentRepository embyRepo, IEmbyContentSync embySync)
{
_settings = s;
_log = log;
_api = plexApi;
_plexRepo = plexRepo;
_plexContentSync = c;
_embyRepo = embyRepo;
_embyContentSync = embySync;
_settings.ClearCache();
}
private readonly ISettingsService<PlexSettings> _settings;
private readonly ILogger _log;
private readonly IPlexApi _api;
private readonly IPlexContentRepository _plexRepo;
private readonly IPlexContentSync _plexContentSync;
private readonly IEmbyContentRepository _embyRepo;
private readonly IEmbyContentSync _embyContentSync;
public async Task Start()
{
try
{
await RemovePlexData();
await RemoveEmbyData();
}
catch (Exception e)
{
_log.LogError(LoggingEvents.MediaReferesh, e, "Refreshing Media Data Failed");
}
}
private async Task RemoveEmbyData()
{
try
{
var s = await _settings.GetSettingsAsync();
if (!s.Enable)
{
return;
}
const string episodeSQL = "DELETE FROM EmbyEpisode";
const string mainSql = "DELETE FROM EmbyContent";
await _embyRepo.ExecuteSql(episodeSQL);
await _embyRepo.ExecuteSql(mainSql);
BackgroundJob.Enqueue(() => _embyContentSync.Start());
}
catch (Exception e)
{
_log.LogError(LoggingEvents.MediaReferesh, e, "Refreshing Emby Data Failed");
}
}
private async Task RemovePlexData()
{
try
{
var s = await _settings.GetSettingsAsync();
if (!s.Enable)
{
return;
}
const string episodeSQL = "DELETE FROM PlexEpisode";
const string seasonsSql = "DELETE FROM PlexSeasonsContent";
const string mainSql = "DELETE FROM PlexServerContent";
await _plexRepo.ExecuteSql(episodeSQL);
await _plexRepo.ExecuteSql(seasonsSql);
await _plexRepo.ExecuteSql(mainSql);
}
catch (Exception e)
{
_log.LogError(LoggingEvents.MediaReferesh, e, "Refreshing Plex Data Failed");
}
}
private bool _disposed;
protected virtual void Dispose(bool disposing)
{
if (_disposed)
return;
if (disposing)
{
_plexRepo?.Dispose();
_settings?.Dispose();
}
_disposed = true;
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
}
}

@ -16,5 +16,6 @@
public string LidarrArtistSync { get; set; }
public string IssuesPurge { get; set; }
public string RetryRequests { get; set; }
public string MediaDatabaseRefresh { get; set; }
}
}

@ -65,7 +65,10 @@ namespace Ombi.Settings.Settings.Models
{
return Get(s.RetryRequests, Cron.Daily(6));
}
public static string MediaDatabaseRefresh(JobSettings s)
{
return Get(s.MediaDatabaseRefresh, Cron.DayInterval(5));
}
private static string Get(string settings, string defaultCron)
{
return settings.HasValue() ? settings : defaultCron;

@ -138,6 +138,7 @@ export interface IJobSettings {
lidarrArtistSync: string;
issuesPurge: string;
retryRequests: string;
mediaDatabaseRefresh: string;
}
export interface IIssueSettings extends ISettings {

@ -105,6 +105,13 @@
<small *ngIf="form.get('issuesPurge').hasError('required')" class="error-text">The Issues Purge is required</small>
<button type="button" class="btn btn-sm btn-primary-outline" (click)="testCron(form.get('issuesPurge')?.value)">Test</button>
</div>
<div class="form-group">
<label for="userImporter" class="control-label">Media Data Refresh</label>
<input type="text" class="form-control form-control-custom" [ngClass]="{'form-error': form.get('mediaDatabaseRefresh').hasError('required')}" id="mediaDatabaseRefresh" name="mediaDatabaseRefresh" formControlName="mediaDatabaseRefresh">
<small *ngIf="form.get('mediaDatabaseRefresh').hasError('required')" class="error-text">The Media Database Refresh is required</small>
<button type="button" class="btn btn-sm btn-primary-outline" (click)="testCron(form.get('mediaDatabaseRefresh')?.value)">Test</button>
</div>
</div>
<div class="form-group">
<div>

@ -37,6 +37,7 @@ export class JobsComponent implements OnInit {
lidarrArtistSync: [x.lidarrArtistSync, Validators.required],
issuesPurge: [x.issuesPurge, Validators.required],
retryRequests: [x.retryRequests, Validators.required],
mediaDatabaseRefresh: [x.mediaDatabaseRefresh, Validators.required],
});
});
}

@ -522,6 +522,7 @@ namespace Ombi.Controllers
j.LidarrArtistSync = j.LidarrArtistSync.HasValue() ? j.LidarrArtistSync : JobSettingsHelper.LidarrArtistSync(j);
j.IssuesPurge = j.IssuesPurge.HasValue() ? j.IssuesPurge : JobSettingsHelper.IssuePurge(j);
j.RetryRequests = j.RetryRequests.HasValue() ? j.RetryRequests : JobSettingsHelper.ResendFailedRequests(j);
j.MediaDatabaseRefresh = j.MediaDatabaseRefresh.HasValue() ? j.MediaDatabaseRefresh : JobSettingsHelper.MediaDatabaseRefresh(j);
return j;
}

Loading…
Cancel
Save