mirror of
https://github.com/Ombi-app/Ombi.git
synced 2025-08-19 04:49:33 -07:00
parent
84ea45ebaa
commit
05bdfcd550
16 changed files with 70 additions and 4 deletions
|
@ -25,6 +25,7 @@
|
||||||
// ************************************************************************/
|
// ************************************************************************/
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using PlexRequests.Helpers.Permissions;
|
using PlexRequests.Helpers.Permissions;
|
||||||
|
@ -36,12 +37,14 @@ namespace PlexRequests.Core.Migration.Migrations
|
||||||
[Migration(11000, "v1.10.0.0")]
|
[Migration(11000, "v1.10.0.0")]
|
||||||
public class Version1100 : BaseMigration, IMigration
|
public class Version1100 : BaseMigration, IMigration
|
||||||
{
|
{
|
||||||
public Version1100(IUserRepository userRepo)
|
public Version1100(IUserRepository userRepo, IRequestService requestService)
|
||||||
{
|
{
|
||||||
UserRepo = userRepo;
|
UserRepo = userRepo;
|
||||||
|
RequestService = requestService;
|
||||||
}
|
}
|
||||||
public int Version => 11000;
|
public int Version => 11000;
|
||||||
private IUserRepository UserRepo { get; }
|
private IUserRepository UserRepo { get; }
|
||||||
|
private IRequestService RequestService { get; }
|
||||||
|
|
||||||
public void Start(IDbConnection con)
|
public void Start(IDbConnection con)
|
||||||
{
|
{
|
||||||
|
@ -50,6 +53,7 @@ namespace PlexRequests.Core.Migration.Migrations
|
||||||
// Update the current admin permissions set
|
// Update the current admin permissions set
|
||||||
UpdateAdmin();
|
UpdateAdmin();
|
||||||
|
|
||||||
|
|
||||||
UpdateSchema(con, Version);
|
UpdateSchema(con, Version);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,6 +63,26 @@ namespace PlexRequests.Core.Migration.Migrations
|
||||||
con.AlterTable("Users", "ADD", "Permissions", true, "INTEGER");
|
con.AlterTable("Users", "ADD", "Permissions", true, "INTEGER");
|
||||||
con.AlterTable("Users", "ADD", "Features", true, "INTEGER");
|
con.AlterTable("Users", "ADD", "Features", true, "INTEGER");
|
||||||
|
|
||||||
|
// Add the new 'running' item into the scheduled jobs so we can check if the cachers are running
|
||||||
|
con.AlterTable("ScheduledJobs", "ADD", "Running", true, "INTEGER");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//https://image.tmdb.org/t/p/w150/https://image.tmdb.org/t/p/w150//aqhAqttDq7zgsTaBHtCD8wmTk6k.jpg
|
||||||
|
|
||||||
|
// UI = https://image.tmdb.org/t/p/w150/{{posterPath}}
|
||||||
|
// Update old invalid posters
|
||||||
|
var allRequests = RequestService.GetAll().ToList();
|
||||||
|
|
||||||
|
foreach (var req in allRequests)
|
||||||
|
{
|
||||||
|
if (req.PosterPath.Contains("https://image.tmdb.org/t/p/w150/"))
|
||||||
|
{
|
||||||
|
var newImg = req.PosterPath.Replace("https://image.tmdb.org/t/p/w150/", string.Empty);
|
||||||
|
req.PosterPath = newImg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
RequestService.BatchUpdate(allRequests);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAdmin()
|
private void UpdateAdmin()
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace PlexRequests.Core
|
||||||
{
|
{
|
||||||
public struct TimeFrameMinutes
|
public struct TimeFrameMinutes
|
||||||
{
|
{
|
||||||
public const int SchedulerCaching = 60;
|
public const int SchedulerCaching = 120;
|
||||||
}
|
}
|
||||||
|
|
||||||
public const string PlexLibaries = nameof(PlexLibaries);
|
public const string PlexLibaries = nameof(PlexLibaries);
|
||||||
|
|
|
@ -36,5 +36,6 @@ namespace PlexRequests.Services.Interfaces
|
||||||
void Record(string jobName);
|
void Record(string jobName);
|
||||||
Task<IEnumerable<ScheduledJobs>> GetJobsAsync();
|
Task<IEnumerable<ScheduledJobs>> GetJobsAsync();
|
||||||
IEnumerable<ScheduledJobs> GetJobs();
|
IEnumerable<ScheduledJobs> GetJobs();
|
||||||
|
void SetRunning(bool running, string jobName);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -81,6 +81,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Job.Record(JobNames.CpCacher);
|
Job.Record(JobNames.CpCacher);
|
||||||
|
Job.SetRunning(false, JobNames.CpCacher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -108,6 +109,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
|
|
||||||
public void Execute(IJobExecutionContext context)
|
public void Execute(IJobExecutionContext context)
|
||||||
{
|
{
|
||||||
|
Job.SetRunning(true, JobNames.CpCacher);
|
||||||
Queued();
|
Queued();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,8 @@ namespace PlexRequests.Services.Jobs
|
||||||
|
|
||||||
public void Execute(IJobExecutionContext context)
|
public void Execute(IJobExecutionContext context)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Record.SetRunning(true, JobNames.CpCacher);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var faultedRequests = Repo.GetAll().ToList();
|
var faultedRequests = Repo.GetAll().ToList();
|
||||||
|
@ -105,6 +107,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Record.Record(JobNames.FaultQueueHandler);
|
Record.Record(JobNames.FaultQueueHandler);
|
||||||
|
Record.SetRunning(false, JobNames.CpCacher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,23 @@ namespace PlexRequests.Services.Jobs
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetRunning(bool running, string jobName)
|
||||||
|
{
|
||||||
|
var allJobs = Repo.GetAll();
|
||||||
|
var storeJob = allJobs.FirstOrDefault(x => x.Name == jobName);
|
||||||
|
if (storeJob != null)
|
||||||
|
{
|
||||||
|
storeJob.Running = running;
|
||||||
|
Repo.Update(storeJob);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var job = new ScheduledJobs { Running = running, Name = jobName };
|
||||||
|
Repo.Insert(job);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<IEnumerable<ScheduledJobs>> GetJobsAsync()
|
public async Task<IEnumerable<ScheduledJobs>> GetJobsAsync()
|
||||||
{
|
{
|
||||||
return await Repo.GetAllAsync();
|
return await Repo.GetAllAsync();
|
||||||
|
|
|
@ -158,7 +158,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
}
|
}
|
||||||
|
|
||||||
Job.Record(JobNames.PlexChecker);
|
Job.Record(JobNames.PlexChecker);
|
||||||
|
Job.SetRunning(false, JobNames.CpCacher);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PlexMovie> GetPlexMovies()
|
public List<PlexMovie> GetPlexMovies()
|
||||||
|
@ -503,6 +503,8 @@ namespace PlexRequests.Services.Jobs
|
||||||
|
|
||||||
public void Execute(IJobExecutionContext context)
|
public void Execute(IJobExecutionContext context)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
Job.SetRunning(true, JobNames.CpCacher);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CheckAndUpdateAll();
|
CheckAndUpdateAll();
|
||||||
|
|
|
@ -145,6 +145,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
|
|
||||||
public void Execute(IJobExecutionContext context)
|
public void Execute(IJobExecutionContext context)
|
||||||
{
|
{
|
||||||
|
Job.SetRunning(true, JobNames.CpCacher);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var s = Plex.GetSettings();
|
var s = Plex.GetSettings();
|
||||||
|
@ -171,6 +172,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Job.Record(JobNames.EpisodeCacher);
|
Job.Record(JobNames.EpisodeCacher);
|
||||||
|
Job.SetRunning(false, JobNames.CpCacher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,6 +78,8 @@ namespace PlexRequests.Services.Jobs
|
||||||
|
|
||||||
public void Execute(IJobExecutionContext context)
|
public void Execute(IJobExecutionContext context)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
JobRecord.SetRunning(true, JobNames.CpCacher);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var settings = NewsletterSettings.GetSettings();
|
var settings = NewsletterSettings.GetSettings();
|
||||||
|
@ -95,6 +97,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
JobRecord.Record(JobNames.RecentlyAddedEmail);
|
JobRecord.Record(JobNames.RecentlyAddedEmail);
|
||||||
|
JobRecord.SetRunning(false, JobNames.CpCacher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
|
|
||||||
public void Queued()
|
public void Queued()
|
||||||
{
|
{
|
||||||
|
Job.SetRunning(true, JobNames.CpCacher);
|
||||||
Log.Trace("Getting the settings");
|
Log.Trace("Getting the settings");
|
||||||
|
|
||||||
var settings = SrSettings.GetSettings();
|
var settings = SrSettings.GetSettings();
|
||||||
|
@ -79,6 +80,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Job.Record(JobNames.SrCacher);
|
Job.Record(JobNames.SrCacher);
|
||||||
|
Job.SetRunning(false, JobNames.CpCacher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
|
|
||||||
public void Queued()
|
public void Queued()
|
||||||
{
|
{
|
||||||
|
Job.SetRunning(true, JobNames.CpCacher);
|
||||||
var settings = SonarrSettings.GetSettings();
|
var settings = SonarrSettings.GetSettings();
|
||||||
if (settings.Enabled)
|
if (settings.Enabled)
|
||||||
{
|
{
|
||||||
|
@ -80,6 +81,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Job.Record(JobNames.SonarrCacher);
|
Job.Record(JobNames.SonarrCacher);
|
||||||
|
Job.SetRunning(false, JobNames.CpCacher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
|
|
||||||
public void Execute(IJobExecutionContext context)
|
public void Execute(IJobExecutionContext context)
|
||||||
{
|
{
|
||||||
|
JobRecord.SetRunning(true, JobNames.CpCacher);
|
||||||
TakeBackup();
|
TakeBackup();
|
||||||
Cleanup();
|
Cleanup();
|
||||||
}
|
}
|
||||||
|
@ -91,6 +92,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
JobRecord.Record(JobNames.StoreBackup);
|
JobRecord.Record(JobNames.StoreBackup);
|
||||||
|
JobRecord.SetRunning(false, JobNames.CpCacher);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,12 +78,14 @@ namespace PlexRequests.Services.Jobs
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
JobRecord.Record(JobNames.StoreCleanup);
|
JobRecord.Record(JobNames.StoreCleanup);
|
||||||
|
JobRecord.SetRunning(false, JobNames.CpCacher);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute(IJobExecutionContext context)
|
public void Execute(IJobExecutionContext context)
|
||||||
{
|
{
|
||||||
|
JobRecord.SetRunning(true, JobNames.CpCacher);
|
||||||
Cleanup();
|
Cleanup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
|
|
||||||
public void Execute(IJobExecutionContext context)
|
public void Execute(IJobExecutionContext context)
|
||||||
{
|
{
|
||||||
|
Record.SetRunning(true, JobNames.CpCacher);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var settings = Settings.GetSettings();
|
var settings = Settings.GetSettings();
|
||||||
|
@ -115,6 +116,7 @@ namespace PlexRequests.Services.Jobs
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Record.Record(JobNames.RequestLimitReset);
|
Record.Record(JobNames.RequestLimitReset);
|
||||||
|
Record.SetRunning(false, JobNames.CpCacher);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,5 +35,6 @@ namespace PlexRequests.Store.Models
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public DateTime LastRun { get; set; }
|
public DateTime LastRun { get; set; }
|
||||||
|
public bool Running { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,8 @@ CREATE TABLE IF NOT EXISTS ScheduledJobs
|
||||||
(
|
(
|
||||||
Id INTEGER PRIMARY KEY AUTOINCREMENT,
|
Id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
Name varchar(100) NOT NULL,
|
Name varchar(100) NOT NULL,
|
||||||
LastRun varchar(100) NOT NULL
|
LastRun varchar(100) NOT NULL,
|
||||||
|
Running INTEGER
|
||||||
);
|
);
|
||||||
CREATE UNIQUE INDEX IF NOT EXISTS ScheduledJobs_Id ON ScheduledJobs (Id);
|
CREATE UNIQUE INDEX IF NOT EXISTS ScheduledJobs_Id ON ScheduledJobs (Id);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue