Skip to content

Commit

Permalink
Adjust jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
stanriders committed Sep 26, 2024
1 parent 7e263a5 commit d944ce2
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 132 deletions.
6 changes: 3 additions & 3 deletions backend/Mutualify/Jobs/UserAllUpdateJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class UserAllUpdateJob : IUserAllUpdateJob
private readonly IUsersService _usersService;
private readonly ILogger<UserUpdateJob> _logger;

private const double _interval = 5; // seconds
private const double _interval = 4; // seconds

private static bool _isRunning = false;
private static DateTime _lastStartDate;
Expand Down Expand Up @@ -91,9 +91,9 @@ public async Task Run(PerformContext context, CancellationToken token)
}
catch (DbUpdateConcurrencyException) { } // don't fail on HttpRequestExceptions or DbUpdateConcurrencyException, just keep going
catch (HttpRequestException) { }
catch (OperationCanceledException)
catch (OperationCanceledException ex)
{
_logger.LogWarning("[{JobId}] All users update job has been cancelled!", jobId);
_logger.LogWarning(ex, "[{JobId}] All users update job has been cancelled!", jobId);

_isRunning = false;
return;
Expand Down
121 changes: 0 additions & 121 deletions backend/Mutualify/Jobs/UserPopulateJob.cs

This file was deleted.

6 changes: 3 additions & 3 deletions backend/Mutualify/Jobs/UserRelationsUpdateJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public class UserRelationsUpdateJob : IUserRelationsUpdateJob
private readonly IRelationsService _relationsService;
private readonly ILogger<UserRelationsUpdateJob> _logger;

private const int _interval = 3; // seconds
private const int _interval = 2; // seconds

private static bool _isRunning = false;
private static DateTime _lastStartDate;
Expand Down Expand Up @@ -81,9 +81,9 @@ public async Task Run(PerformContext context, CancellationToken token)
}
catch (DbUpdateConcurrencyException) { } // don't fail on HttpRequestExceptions or DbUpdateConcurrencyException, just keep going
catch (HttpRequestException) { }
catch (OperationCanceledException)
catch (OperationCanceledException ex)
{
_logger.LogWarning("[{JobId}] User relations update job has been cancelled!", jobId);
_logger.LogWarning(ex, "[{JobId}] User relations update job has been cancelled!", jobId);

_isRunning = false;
return;
Expand Down
4 changes: 2 additions & 2 deletions backend/Mutualify/Jobs/UserUpdateJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ public async Task Run(PerformContext context, CancellationToken token)
}
catch (DbUpdateConcurrencyException) { } // don't fail on HttpRequestExceptions or DbUpdateConcurrencyException, just keep going
catch (HttpRequestException) { }
catch (OperationCanceledException)
catch (OperationCanceledException ex)
{
_logger.LogWarning("[{JobId}] User update job has been cancelled!", jobId);
_logger.LogWarning(ex, "[{JobId}] User update job has been cancelled!", jobId);

_isRunning = false;
return;
Expand Down
3 changes: 0 additions & 3 deletions backend/Mutualify/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using FastExpressionCompiler;
using Hangfire;
using Hangfire.PostgreSql;
using Hangfire.PostgreSql.Factories;
using Mapster;
using MapsterMapper;
using Microsoft.AspNetCore.Authentication;
Expand Down Expand Up @@ -130,7 +129,6 @@ static Task UnauthorizedRedirect(RedirectContext<CookieAuthenticationOptions> co

builder.Services.AddTransient<IUserRelationsUpdateJob, UserRelationsUpdateJob>();
builder.Services.AddTransient<IUserUpdateJob, UserUpdateJob>();
builder.Services.AddTransient<IUserPopulateJob, UserPopulateJob>();
builder.Services.AddTransient<IUserAllUpdateJob, UserAllUpdateJob>();

builder.Services.AddControllers().AddNewtonsoftJson(options =>
Expand Down Expand Up @@ -242,7 +240,6 @@ static Task UnauthorizedRedirect(RedirectContext<CookieAuthenticationOptions> co
RecurringJob.AddOrUpdate<IUserUpdateJob>("users-update", x => x.Run(null!, CancellationToken.None), Cron.Daily());
RecurringJob.AddOrUpdate<IUserAllUpdateJob>("users-update-all", x => x.Run(null!, CancellationToken.None),
Cron.Monthly(3));
//BackgroundJob.Enqueue<IUserPopulateJob>(x => x.Run(null!, JobCancellationToken.Null));
}

try
Expand Down

0 comments on commit d944ce2

Please sign in to comment.