Implement TaskTriggerInfoType enum (#12783)

This commit is contained in:
Ethan Pippin 2024-12-01 17:08:37 -07:00 committed by GitHub
parent 9ae1ac2513
commit 06923cbf2b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
19 changed files with 52 additions and 44 deletions

View file

@ -471,7 +471,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
new()
{
IntervalTicks = TimeSpan.FromDays(1).Ticks,
Type = TaskTriggerInfo.TriggerInterval
Type = TaskTriggerInfoType.IntervalTrigger
}
];
}
@ -616,7 +616,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
MaxRuntimeTicks = info.MaxRuntimeTicks
};
if (info.Type.Equals(nameof(DailyTrigger), StringComparison.OrdinalIgnoreCase))
if (info.Type == TaskTriggerInfoType.DailyTrigger)
{
if (!info.TimeOfDayTicks.HasValue)
{
@ -626,7 +626,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
return new DailyTrigger(TimeSpan.FromTicks(info.TimeOfDayTicks.Value), options);
}
if (info.Type.Equals(nameof(WeeklyTrigger), StringComparison.OrdinalIgnoreCase))
if (info.Type == TaskTriggerInfoType.WeeklyTrigger)
{
if (!info.TimeOfDayTicks.HasValue)
{
@ -641,7 +641,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
return new WeeklyTrigger(TimeSpan.FromTicks(info.TimeOfDayTicks.Value), info.DayOfWeek.Value, options);
}
if (info.Type.Equals(nameof(IntervalTrigger), StringComparison.OrdinalIgnoreCase))
if (info.Type == TaskTriggerInfoType.IntervalTrigger)
{
if (!info.IntervalTicks.HasValue)
{
@ -651,7 +651,7 @@ namespace Emby.Server.Implementations.ScheduledTasks
return new IntervalTrigger(TimeSpan.FromTicks(info.IntervalTicks.Value), options);
}
if (info.Type.Equals(nameof(StartupTrigger), StringComparison.OrdinalIgnoreCase))
if (info.Type == TaskTriggerInfoType.StartupTrigger)
{
return new StartupTrigger(options);
}

View file

@ -156,7 +156,7 @@ public partial class AudioNormalizationTask : IScheduledTask
[
new TaskTriggerInfo
{
Type = TaskTriggerInfo.TriggerInterval,
Type = TaskTriggerInfoType.IntervalTrigger,
IntervalTicks = TimeSpan.FromHours(24).Ticks
}
];

View file

@ -80,7 +80,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
[
new TaskTriggerInfo
{
Type = TaskTriggerInfo.TriggerDaily,
Type = TaskTriggerInfoType.DailyTrigger,
TimeOfDayTicks = TimeSpan.FromHours(2).Ticks,
MaxRuntimeTicks = TimeSpan.FromHours(4).Ticks
}

View file

@ -135,6 +135,6 @@ public class CleanupCollectionAndPlaylistPathsTask : IScheduledTask
/// <inheritdoc />
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
return [new TaskTriggerInfo() { Type = TaskTriggerInfo.TriggerStartup }];
return [new TaskTriggerInfo() { Type = TaskTriggerInfoType.StartupTrigger }];
}
}

View file

@ -73,7 +73,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
return
[
// Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks }
new TaskTriggerInfo { Type = TaskTriggerInfoType.IntervalTrigger, IntervalTicks = TimeSpan.FromHours(24).Ticks }
];
}

View file

@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
{
return
[
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks }
new TaskTriggerInfo { Type = TaskTriggerInfoType.IntervalTrigger, IntervalTicks = TimeSpan.FromHours(24).Ticks }
];
}

View file

@ -69,11 +69,11 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
[
new TaskTriggerInfo
{
Type = TaskTriggerInfo.TriggerStartup
Type = TaskTriggerInfoType.StartupTrigger
},
new TaskTriggerInfo
{
Type = TaskTriggerInfo.TriggerInterval,
Type = TaskTriggerInfoType.IntervalTrigger,
IntervalTicks = TimeSpan.FromHours(24).Ticks
}
];

View file

@ -111,7 +111,7 @@ public class MediaSegmentExtractionTask : IScheduledTask
{
yield return new TaskTriggerInfo
{
Type = TaskTriggerInfo.TriggerInterval,
Type = TaskTriggerInfoType.IntervalTrigger,
IntervalTicks = TimeSpan.FromHours(12).Ticks
};
}

View file

@ -62,7 +62,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
return
[
// Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks }
new TaskTriggerInfo { Type = TaskTriggerInfoType.IntervalTrigger, IntervalTicks = TimeSpan.FromHours(24).Ticks }
];
}

View file

@ -58,7 +58,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
{
new TaskTriggerInfo
{
Type = TaskTriggerInfo.TriggerInterval,
Type = TaskTriggerInfoType.IntervalTrigger,
IntervalTicks = TimeSpan.FromDays(7).Ticks
}
};

View file

@ -60,10 +60,10 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
public IEnumerable<TaskTriggerInfo> GetDefaultTriggers()
{
// At startup
yield return new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerStartup };
yield return new TaskTriggerInfo { Type = TaskTriggerInfoType.StartupTrigger };
// Every so often
yield return new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks };
yield return new TaskTriggerInfo { Type = TaskTriggerInfoType.IntervalTrigger, IntervalTicks = TimeSpan.FromHours(24).Ticks };
}
/// <inheritdoc />

View file

@ -48,7 +48,7 @@ namespace Emby.Server.Implementations.ScheduledTasks.Tasks
{
yield return new TaskTriggerInfo
{
Type = TaskTriggerInfo.TriggerInterval,
Type = TaskTriggerInfoType.IntervalTrigger,
IntervalTicks = TimeSpan.FromHours(12).Ticks
};
}

View file

@ -8,31 +8,11 @@ namespace MediaBrowser.Model.Tasks
/// </summary>
public class TaskTriggerInfo
{
/// <summary>
/// The daily trigger.
/// </summary>
public const string TriggerDaily = "DailyTrigger";
/// <summary>
/// The weekly trigger.
/// </summary>
public const string TriggerWeekly = "WeeklyTrigger";
/// <summary>
/// The interval trigger.
/// </summary>
public const string TriggerInterval = "IntervalTrigger";
/// <summary>
/// The startup trigger.
/// </summary>
public const string TriggerStartup = "StartupTrigger";
/// <summary>
/// Gets or sets the type.
/// </summary>
/// <value>The type.</value>
public string Type { get; set; }
public TaskTriggerInfoType Type { get; set; }
/// <summary>
/// Gets or sets the time of day.

View file

@ -0,0 +1,28 @@
namespace MediaBrowser.Model.Tasks
{
/// <summary>
/// Enum TaskTriggerInfoType.
/// </summary>
public enum TaskTriggerInfoType
{
/// <summary>
/// The daily trigger.
/// </summary>
DailyTrigger,
/// <summary>
/// The weekly trigger.
/// </summary>
WeeklyTrigger,
/// <summary>
/// The interval trigger.
/// </summary>
IntervalTrigger,
/// <summary>
/// The startup trigger.
/// </summary>
StartupTrigger
}
}

View file

@ -162,7 +162,7 @@ public class LyricScheduledTask : IScheduledTask
[
new TaskTriggerInfo
{
Type = TaskTriggerInfo.TriggerInterval,
Type = TaskTriggerInfoType.IntervalTrigger,
IntervalTicks = TimeSpan.FromHours(24).Ticks
}
];

View file

@ -217,7 +217,7 @@ namespace MediaBrowser.Providers.MediaInfo
return new[]
{
// Every so often
new TaskTriggerInfo { Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks }
new TaskTriggerInfo { Type = TaskTriggerInfoType.IntervalTrigger, IntervalTicks = TimeSpan.FromHours(24).Ticks }
};
}
}

View file

@ -63,7 +63,7 @@ public class TrickplayImagesTask : IScheduledTask
{
new TaskTriggerInfo
{
Type = TaskTriggerInfo.TriggerDaily,
Type = TaskTriggerInfoType.DailyTrigger,
TimeOfDayTicks = TimeSpan.FromHours(3).Ticks
}
};

View file

@ -79,7 +79,7 @@ namespace Jellyfin.LiveTv.Channels
// Every so often
new TaskTriggerInfo
{
Type = TaskTriggerInfo.TriggerInterval, IntervalTicks = TimeSpan.FromHours(24).Ticks
Type = TaskTriggerInfoType.IntervalTrigger, IntervalTicks = TimeSpan.FromHours(24).Ticks
}
};
}

View file

@ -66,7 +66,7 @@ public class RefreshGuideScheduledTask : IScheduledTask, IConfigurableScheduledT
{
new TaskTriggerInfo
{
Type = TaskTriggerInfo.TriggerInterval,
Type = TaskTriggerInfoType.IntervalTrigger,
IntervalTicks = TimeSpan.FromHours(24).Ticks
}
};