Skip to content

Commit

Permalink
Feature/task 7119 user archival job (#2275)
Browse files Browse the repository at this point in the history
* Implemented task 7119 user archival job

* Change done in user archival job
  • Loading branch information
jukibaskar-bc authored Dec 21, 2023
1 parent 2aedac7 commit 83ab068
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,17 @@ public async void ArchiveUsers(UserDataResponseInfo userDetails)
_logger.LogInformation($"User Dormanted By: {user.DormantBy}, User Dormanted on UTC: {user.DormantedOnUtc}, User IsDormanted: {user.IsDormant}");
DateTime currentDate = _dateTimeService.GetUTCNow();
DateTime dt = currentDate.AddMinutes(-(user.DormantBy == DormantBy.Manual ? _appSettings.DormancyJobSettings.AdminDormantedUserArchivalDurationInMinutes : _appSettings.DormancyJobSettings.JobDormantedUserArchivalDurationInMinutes));
_logger.LogInformation($"User dormanted date should be less than : {dt}");

_logger.LogInformation($"User dormanted date should be less than or equal to : {dt.Date}");
_logger.LogInformation("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
if (user.IsDormant && user.DormantedOnUtc < dt)
if (user.IsDormant && user.DormantedOnUtc != null && user.DormantedOnUtc.Value.Date <= dt.Date)
{
_logger.LogInformation("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
_logger.LogInformation($"User to be archived: {user.UserName}");
_logger.LogInformation("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");

try
{
if (_appSettings.TestModeSettings.Enable)
{
if (user.UserName.Contains(_appSettings.TestModeSettings.Keyword))
Expand All @@ -105,6 +108,11 @@ public async void ArchiveUsers(UserDataResponseInfo userDetails)
{
await _wrapperUserService.DeleteUserAsync(user.UserName, true);
}
}
catch (Exception ex)
{
_logger.LogError($"*****Error while deleting the user {user.UserName}, exception message = {ex.Message}");
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion api/CcsSso.Core.DormancyJobScheduler/appsecrets.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"ArchivalJobFrequencyInMinutes": 1440,
"AdminDormantedUserArchivalDurationInMinutes": 788401, //18 months
"JobDormantedUserArchivalDurationInMinutes": 262800, //6 months
"UserArchivalJobEnable": true
"UserArchivalJobEnable": true
},
"WrapperApiSettings": {
"UserApiKey": "",
Expand Down

0 comments on commit 83ab068

Please sign in to comment.