Added refreshed since for channels
This commit is contained in:
@ -13,6 +13,15 @@ namespace YTManager.Controllers {
|
||||
[Produces("application/json")]
|
||||
[Route("api/Admin")]
|
||||
public class AdminController : Controller {
|
||||
// Get the mass update daemon job.
|
||||
private static RecurringJobDto get_massupdatedaemon() {
|
||||
return Hangfire.JobStorage
|
||||
.Current
|
||||
.GetConnection()
|
||||
.GetRecurringJobs()
|
||||
.SingleOrDefault(j => j.Id == Mass_Updater_ID);
|
||||
}
|
||||
|
||||
// ID for mass update job, used to tell if the job is running or not.
|
||||
public static string Mass_Updater_ID { get; } = "2013066213";
|
||||
|
||||
@ -36,9 +45,12 @@ namespace YTManager.Controllers {
|
||||
// Ensures that the background YT Channel update API is running.
|
||||
[HttpPost("Start_Updater")]
|
||||
public IActionResult Start_Updater() {
|
||||
Hangfire.RecurringJob.AddOrUpdate(
|
||||
Mass_Updater_ID,
|
||||
() => Tasks.FetchVideos.MassUpdate(Startup.DBStr), Hangfire.Cron.Hourly);
|
||||
if (get_massupdatedaemon() == null) {
|
||||
Hangfire.RecurringJob.AddOrUpdate(
|
||||
Mass_Updater_ID,
|
||||
() => Tasks.FetchVideos.MassUpdate(Startup.DBStr), Hangfire.Cron.Minutely);
|
||||
}
|
||||
|
||||
return Ok();
|
||||
}
|
||||
|
||||
@ -46,8 +58,7 @@ namespace YTManager.Controllers {
|
||||
// Check if the periodic update job is enqued.
|
||||
[HttpGet("Update")]
|
||||
public IActionResult Get_Update_Status() {
|
||||
bool exists = Hangfire.JobStorage.Current.GetConnection().GetRecurringJobs().Any(j => j.Id == Mass_Updater_ID);
|
||||
return Ok(exists ? "true" : "false");
|
||||
return Ok(get_massupdatedaemon() == null ? "false" : "true");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user