diff --git a/CleanArchitecture.Api/BackgroundServices/SetInactiveUsersService.cs b/CleanArchitecture.Api/BackgroundServices/SetInactiveUsersService.cs index 4988645..8c94c7a 100644 --- a/CleanArchitecture.Api/BackgroundServices/SetInactiveUsersService.cs +++ b/CleanArchitecture.Api/BackgroundServices/SetInactiveUsersService.cs @@ -37,9 +37,11 @@ public sealed class SetInactiveUsersService : BackgroundService try { + var cutoffDate = DateTimeOffset.UtcNow.AddDays(-30); + inactiveUsers = await context.Users .Where(user => - user.LastLoggedinDate < DateTime.UtcNow.AddDays(-30) && + user.LastLoggedinDate < cutoffDate && user.Status == UserStatus.Active) .Take(250) .ToListAsync(stoppingToken);