From 8c890ea9b05461c28835087c8b6a4f1051cdfd9e Mon Sep 17 00:00:00 2001 From: Moons Date: Tue, 2 Jan 2024 16:34:54 +0100 Subject: [PATCH] fix(tasks): add start time to debug --- Routes/TaskRoute.cs | 4 +++- Services/SchedulerService.cs | 15 ++++++++------- Tasks/UserRefresh.cs | 3 ++- Tasks/VendorsAdepts.cs | 3 ++- Tasks/VendorsGunsmith.cs | 3 ++- Tasks/VendorsIronBanner.cs | 3 ++- Tasks/VendorsTrials.cs | 3 ++- Tasks/VendorsWarTable.cs | 3 ++- 8 files changed, 23 insertions(+), 14 deletions(-) diff --git a/Routes/TaskRoute.cs b/Routes/TaskRoute.cs index f514f16..86b961a 100644 --- a/Routes/TaskRoute.cs +++ b/Routes/TaskRoute.cs @@ -20,7 +20,9 @@ public static void MapTasks(this RouteGroupBuilder group) response.Response.Add(new { task.Name, - task.LastRun + task.IsRunning, + task.StartTime, + task.EndTime }); return TypedResults.Json(response, Common.JsonSerializerOptions); diff --git a/Services/SchedulerService.cs b/Services/SchedulerService.cs index 64db0b6..1d79f11 100644 --- a/Services/SchedulerService.cs +++ b/Services/SchedulerService.cs @@ -14,17 +14,17 @@ protected override Task ExecuteAsync(CancellationToken stoppingToken) try { TaskSchedulerService.Tasks.Add(new ScheduledTask - { Name = "UserRefresh", IsRunning = false, LastRun = null }); + { Name = "UserRefresh", IsRunning = false }); TaskSchedulerService.Tasks.Add(new ScheduledTask - { Name = "VendorsAdepts", IsRunning = false, LastRun = null }); + { Name = "VendorsAdepts", IsRunning = false }); TaskSchedulerService.Tasks.Add(new ScheduledTask - { Name = "VendorsGunsmith", IsRunning = false, LastRun = null }); + { Name = "VendorsGunsmith", IsRunning = false }); TaskSchedulerService.Tasks.Add(new ScheduledTask - { Name = "VendorsIronBanner", IsRunning = false, LastRun = null }); + { Name = "VendorsIronBanner", IsRunning = false }); TaskSchedulerService.Tasks.Add(new ScheduledTask - { Name = "VendorsTrials", IsRunning = false, LastRun = null }); + { Name = "VendorsTrials", IsRunning = false }); TaskSchedulerService.Tasks.Add(new ScheduledTask - { Name = "VendorsWarTable", IsRunning = false, LastRun = null }); + { Name = "VendorsWarTable", IsRunning = false }); } catch (Exception e) { @@ -44,5 +44,6 @@ public class ScheduledTask { public string Name { get; init; } = "Unknown Task"; public bool IsRunning { get; set; } - public DateTime? LastRun { get; set; } + public DateTime? StartTime { get; set; } + public DateTime? EndTime { get; set; } } diff --git a/Tasks/UserRefresh.cs b/Tasks/UserRefresh.cs index ae98ce4..a751480 100644 --- a/Tasks/UserRefresh.cs +++ b/Tasks/UserRefresh.cs @@ -23,6 +23,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) while (!stoppingToken.IsCancellationRequested) { TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).IsRunning = true; + TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).StartTime = DateTime.UtcNow; try { @@ -144,7 +145,7 @@ await DiscordTools.SendMessage(DiscordTools.WebhookChannel.Logs, } TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).IsRunning = false; - TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).LastRun = DateTime.UtcNow; + TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).EndTime = DateTime.UtcNow; await Task.Delay(DateTimeExtensions.GetRoundTimeSpan(60), stoppingToken); } diff --git a/Tasks/VendorsAdepts.cs b/Tasks/VendorsAdepts.cs index eee3565..164e3a3 100644 --- a/Tasks/VendorsAdepts.cs +++ b/Tasks/VendorsAdepts.cs @@ -32,6 +32,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) await Task.Delay(DateTimeExtensions.GetRoundTimeSpan(1), stoppingToken); TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).IsRunning = true; + TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).StartTime = DateTime.UtcNow; var nfAdept = "None"; var trialsAdept = "None"; @@ -206,7 +207,7 @@ await DiscordTools.SendMessage(DiscordTools.WebhookChannel.Vendors, } TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).IsRunning = false; - TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).LastRun = DateTime.UtcNow; + TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).EndTime = DateTime.UtcNow; await bungieClient.ResetService.WaitForNextDailyReset(TimeSpan.FromMinutes(1), stoppingToken); } diff --git a/Tasks/VendorsGunsmith.cs b/Tasks/VendorsGunsmith.cs index d4e3c98..b2cfdae 100644 --- a/Tasks/VendorsGunsmith.cs +++ b/Tasks/VendorsGunsmith.cs @@ -27,6 +27,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) await Task.Delay(DateTimeExtensions.GetRoundTimeSpan(1), stoppingToken); TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).IsRunning = true; + TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).StartTime = DateTime.UtcNow; try { @@ -66,7 +67,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) } TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).IsRunning = false; - TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).LastRun = DateTime.UtcNow; + TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).EndTime = DateTime.UtcNow; await Task.Delay(DateTimeExtensions.GetRoundTimeSpan(60), stoppingToken); } diff --git a/Tasks/VendorsIronBanner.cs b/Tasks/VendorsIronBanner.cs index e11d0b8..ac5364f 100644 --- a/Tasks/VendorsIronBanner.cs +++ b/Tasks/VendorsIronBanner.cs @@ -28,6 +28,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) await Task.Delay(DateTimeExtensions.GetRoundTimeSpan(1), stoppingToken); TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).IsRunning = true; + TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).StartTime = DateTime.UtcNow; try { @@ -84,7 +85,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) } TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).IsRunning = false; - TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).LastRun = DateTime.UtcNow; + TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).EndTime = DateTime.UtcNow; await Task.Delay(DateTimeExtensions.GetRoundTimeSpan(60), stoppingToken); } diff --git a/Tasks/VendorsTrials.cs b/Tasks/VendorsTrials.cs index 0e07249..0048f0e 100644 --- a/Tasks/VendorsTrials.cs +++ b/Tasks/VendorsTrials.cs @@ -28,6 +28,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) await Task.Delay(DateTimeExtensions.GetRoundTimeSpan(1), stoppingToken); TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).IsRunning = true; + TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).StartTime = DateTime.UtcNow; try { @@ -84,7 +85,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) } TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).IsRunning = false; - TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).LastRun = DateTime.UtcNow; + TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).EndTime = DateTime.UtcNow; await Task.Delay(DateTimeExtensions.GetRoundTimeSpan(60), stoppingToken); } diff --git a/Tasks/VendorsWarTable.cs b/Tasks/VendorsWarTable.cs index 04fcddd..b5d8d7c 100644 --- a/Tasks/VendorsWarTable.cs +++ b/Tasks/VendorsWarTable.cs @@ -27,6 +27,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) await Task.Delay(DateTimeExtensions.GetRoundTimeSpan(1), stoppingToken); TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).IsRunning = true; + TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).StartTime = DateTime.UtcNow; try { @@ -66,7 +67,7 @@ protected override async Task ExecuteAsync(CancellationToken stoppingToken) } TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).IsRunning = false; - TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).LastRun = DateTime.UtcNow; + TaskSchedulerService.Tasks.First(t => t.Name == ServiceName).EndTime = DateTime.UtcNow; await Task.Delay(DateTimeExtensions.GetRoundTimeSpan(60), stoppingToken); }