-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #764 from bcgov/develop
promote
- Loading branch information
Showing
22 changed files
with
190 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
backend/webapi/Features/SanityChecks/DelegateRequests/DelegateAccessChecks.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
namespace Pidp.Features.SanityChecks.DelegateRequests; | ||
|
||
using System.Threading.Tasks; | ||
using Microsoft.EntityFrameworkCore; | ||
using NodaTime; | ||
using Pidp.Data; | ||
|
||
public class DelegateAccessChecks(ILogger<DelegateAccessChecks> logger, PidpConfiguration configuration, PidpDbContext context, IClock clock) : IDelegateAccessChecks | ||
{ | ||
public async Task<int> FlagExpiredRequestsAsync() | ||
{ | ||
var expiredDate = clock.GetCurrentInstant().Minus(Duration.FromDays(configuration.DelegateAccessExpiryDays)); | ||
var expiredRequests = await context.DelegateAccessRequests | ||
.Where(req => req.RequestStatus == "Submitted" && req.Created < expiredDate).ToListAsync(); | ||
|
||
foreach (var request in expiredRequests) | ||
{ | ||
// Update request status or perform other actions | ||
request.RequestStatus = "Expired"; | ||
request.ResponseDate = clock.GetCurrentInstant(); | ||
} | ||
|
||
if (expiredRequests.Count > 0) | ||
{ | ||
logger.LogInformation($"Flagged {expiredRequests.Count} expired requests"); | ||
} | ||
|
||
return await context.SaveChangesAsync(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
backend/webapi/Features/SanityChecks/DelegateRequests/DelegateAccessSanityCheckTask.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace Pidp.Features.SanityChecks.DelegateRequests; | ||
|
||
using Quartz; | ||
|
||
[PersistJobDataAfterExecution] | ||
[DisallowConcurrentExecution] | ||
public class DelegateAccessSanityCheckTask(ILogger<DelegateAccessSanityCheckTask> logger, IDelegateAccessChecks delegateChecks) : IJob | ||
{ | ||
|
||
public async Task Execute(IJobExecutionContext context) | ||
{ | ||
logger.LogDebug("Delegate sanity check task started"); | ||
|
||
var updates = await delegateChecks.FlagExpiredRequestsAsync(); | ||
if (updates > 0) | ||
{ | ||
logger.LogInformation($"Flagged {updates} expired requests"); | ||
} | ||
|
||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
backend/webapi/Features/SanityChecks/DelegateRequests/IDelegateAccessChecks.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
namespace Pidp.Features.SanityChecks.DelegateRequests; | ||
|
||
public interface IDelegateAccessChecks | ||
{ | ||
public Task<int> FlagExpiredRequestsAsync(); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.