mirror of
https://github.com/Prowlarr/Prowlarr.git
synced 2025-09-17 17:14:18 +02:00
New: Scheduled tasks shwon in UI under System
This commit is contained in:
37
src/NzbDrone.Api/System/Tasks/TaskModule.cs
Normal file
37
src/NzbDrone.Api/System/Tasks/TaskModule.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using NzbDrone.Core.Jobs;
|
||||
|
||||
namespace NzbDrone.Api.System.Tasks
|
||||
{
|
||||
public class TaskModule : NzbDroneRestModule<TaskResource>
|
||||
{
|
||||
private readonly ITaskManager _taskManager;
|
||||
|
||||
public TaskModule(ITaskManager taskManager)
|
||||
: base("system/task")
|
||||
{
|
||||
_taskManager = taskManager;
|
||||
GetResourceAll = GetAll;
|
||||
}
|
||||
|
||||
private List<TaskResource> GetAll()
|
||||
{
|
||||
return _taskManager.GetAll().Select(ConvertToResource).ToList();
|
||||
}
|
||||
|
||||
private static TaskResource ConvertToResource(ScheduledTask scheduledTask)
|
||||
{
|
||||
return new TaskResource
|
||||
{
|
||||
Id = scheduledTask.Id,
|
||||
Name = scheduledTask.TypeName.Split('.').Last().Replace("Command", ""),
|
||||
CommandName = scheduledTask.TypeName.Split('.').Last(),
|
||||
Interval = scheduledTask.Interval,
|
||||
LastExecution = scheduledTask.LastExecution,
|
||||
NextExecution = scheduledTask.LastExecution.AddMinutes(scheduledTask.Interval)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user