Skip to content

Commit

Permalink
fix(tasks): add start time to debug
Browse files Browse the repository at this point in the history
  • Loading branch information
MoonieGZ committed Jan 2, 2024
1 parent f808774 commit 8c890ea
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 14 deletions.
4 changes: 3 additions & 1 deletion Routes/TaskRoute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
15 changes: 8 additions & 7 deletions Services/SchedulerService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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; }
}
3 changes: 2 additions & 1 deletion Tasks/UserRefresh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion Tasks/VendorsAdepts.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion Tasks/VendorsGunsmith.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion Tasks/VendorsIronBanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion Tasks/VendorsTrials.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
}
Expand Down
3 changes: 2 additions & 1 deletion Tasks/VendorsWarTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 8c890ea

Please sign in to comment.