Skip to content

Commit

Permalink
Update AzuraChecksBackgroundTask.cs
Browse files Browse the repository at this point in the history
Signed-off-by: Sellara <147769367+Sella-GH@users.noreply.github.com>
  • Loading branch information
Sella-GH authored Nov 7, 2024
1 parent e6f4dc9 commit ba30fc8
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task QueueApiPermissionChecksAsync(IAsyncEnumerable<GuildEntity> gu
int counter = 0;
await foreach (GuildEntity guild in guilds)
{
if (guild.AzuraCast?.IsOnline is true && now > guild.AzuraCast.Checks.LastServerStatusCheck.AddMinutes(14.98))
if (guild.AzuraCast?.IsOnline is true && now - guild.AzuraCast.Checks.LastServerStatusCheck > TimeSpan.FromHours(11.98))
{
_ = Task.Run(async () => await _queue.QueueBackgroundWorkItemAsync(async ct => await _apiService.CheckForApiPermissionsAsync(guild.AzuraCast)));
counter++;
Expand Down Expand Up @@ -84,7 +84,7 @@ public async Task QueueFileChangesChecksAsync(IAsyncEnumerable<GuildEntity> guil
int counter = 0;
await foreach (GuildEntity guild in guilds.Where(g => g.AzuraCast?.IsOnline == true))
{
foreach (AzuraCastStationEntity station in guild.AzuraCast!.Stations.Where(s => s.Checks.FileChanges && now > s.Checks.LastFileChangesCheck.AddHours(0.98)))
foreach (AzuraCastStationEntity station in guild.AzuraCast!.Stations.Where(s => s.Checks.FileChanges && now - s.Checks.LastFileChangesCheck > TimeSpan.FromHours(0.98)))
{
_ = Task.Run(async () => await _queue.QueueBackgroundWorkItemAsync(async ct => await _fileService.CheckForFileChangesAsync(station, ct)));
counter++;
Expand Down Expand Up @@ -137,7 +137,7 @@ public async Task QueueInstancePingAsync(IAsyncEnumerable<GuildEntity> guilds, D
int counter = 0;
await foreach (GuildEntity guild in guilds)
{
if (guild.AzuraCast?.Checks.ServerStatus is true && now > guild.AzuraCast?.Checks.LastServerStatusCheck.AddMinutes(14.98))
if (guild.AzuraCast?.Checks.ServerStatus is true && now - guild.AzuraCast.Checks.LastServerStatusCheck > TimeSpan.FromMinutes(14.98))

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
guild.AzuraCast
may be null at this access as suggested by
this
null check.
{
_ = Task.Run(async () => await _queue.QueueBackgroundWorkItemAsync(async ct => await _pingService.PingInstanceAsync(guild.AzuraCast, ct)));
counter++;
Expand Down Expand Up @@ -173,7 +173,7 @@ public async Task QueueUpdatesAsync(IAsyncEnumerable<GuildEntity> guilds, DateTi
int counter = 0;
await foreach (GuildEntity guild in guilds)
{
if (guild.AzuraCast?.IsOnline is true && guild.AzuraCast.Checks.Updates && now > guild.AzuraCast.Checks.LastUpdateCheck.AddHours(11.98))
if (guild.AzuraCast?.IsOnline is true && guild.AzuraCast.Checks.Updates && now - guild.AzuraCast.Checks.LastUpdateCheck > TimeSpan.FromHours(11.98))
{
_ = Task.Run(async () => await _queue.QueueBackgroundWorkItemAsync(async ct => await _updaterService.CheckForAzuraCastUpdatesAsync(guild.AzuraCast!, ct)));
counter++;
Expand Down

0 comments on commit ba30fc8

Please sign in to comment.