diff --git a/src/Communication/Communication.Types/ICommunicationRepository.cs b/src/Communication/Communication.Types/ICommunicationRepository.cs index 183e487436..c45b140ece 100644 --- a/src/Communication/Communication.Types/ICommunicationRepository.cs +++ b/src/Communication/Communication.Types/ICommunicationRepository.cs @@ -12,6 +12,6 @@ public interface ICommunicationRepository Task UpdateAsync(CommunicationMessage commMsg); Task> GetScheduledMessagesSinceAsync(string requestType, DeliveryFrequency frequency, DateTime from, DateTime to); Task UpdateScheduledMessagesAsSentAsync(IEnumerable msgIds, Guid aggregatedMessageId); - Task HardDelete(DateTime dispatchDateTime); + Task HardDelete(DateTime hardDeleteCommunicationMessagesStaleDateTime); } } \ No newline at end of file diff --git a/src/Data/CosmosDb/Console.RecruitSeedDataWriter/Data/RecruitWebJobsSystem.json b/src/Data/CosmosDb/Console.RecruitSeedDataWriter/Data/RecruitWebJobsSystem.json index d7bda5dce0..6528f735ff 100644 --- a/src/Data/CosmosDb/Console.RecruitSeedDataWriter/Data/RecruitWebJobsSystem.json +++ b/src/Data/CosmosDb/Console.RecruitSeedDataWriter/Data/RecruitWebJobsSystem.json @@ -3,5 +3,6 @@ "disabledJobs" : ["VacancyAnalyticsSummaryGeneratorJob"], "queryStoreDocumentsStaleByDays" : 90, "draftVacanciesStaleByDays" : 180, - "referredVacanciesStaleByDays" : 90 + "referredVacanciesStaleByDays" : 90, + "hardDeleteCommunicationMessagesStaleByDays" : 180 } \ No newline at end of file diff --git a/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/Triggers/QueueTriggers/CommunicationsHouseKeepingQueueTriggerTests.cs b/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/Triggers/QueueTriggers/CommunicationsHouseKeepingQueueTriggerTests.cs index 075f446a86..337d89ad0e 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/Triggers/QueueTriggers/CommunicationsHouseKeepingQueueTriggerTests.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs.UnitTests/Triggers/QueueTriggers/CommunicationsHouseKeepingQueueTriggerTests.cs @@ -14,8 +14,9 @@ namespace Recruit.Vacancies.Jobs.UnitTests.Triggers.QueueTriggers { public class CommunicationsHouseKeepingQueueTriggerTests { + private const int Days = 180; private readonly Mock> _loggerMock = new Mock>(); - private readonly RecruitWebJobsSystemConfiguration _jobsConfig = new RecruitWebJobsSystemConfiguration() { }; + private readonly RecruitWebJobsSystemConfiguration _jobsConfig = new RecruitWebJobsSystemConfiguration() { HardDeleteCommunicationMessagesStaleByDays = Days }; private readonly Mock _timeProviderMock = new Mock(); private readonly Mock _communicationRepositoryMock = new Mock(); diff --git a/src/Jobs/Recruit.Vacancies.Jobs/Configuration/RecruitWebJobsSystemConfiguration.cs b/src/Jobs/Recruit.Vacancies.Jobs/Configuration/RecruitWebJobsSystemConfiguration.cs index 16057036f4..35f160a694 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs/Configuration/RecruitWebJobsSystemConfiguration.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs/Configuration/RecruitWebJobsSystemConfiguration.cs @@ -9,5 +9,6 @@ public class RecruitWebJobsSystemConfiguration public int? QueryStoreDocumentsStaleByDays { get; set; } public int? DraftVacanciesStaleByDays { get; set; } public int? ReferredVacanciesStaleByDays { get; set; } + public int? HardDeleteCommunicationMessagesStaleByDays { get; set; } } } \ No newline at end of file diff --git a/src/Jobs/Recruit.Vacancies.Jobs/Triggers/QueueTriggers/CommunicationsHouseKeepingQueueTrigger.cs b/src/Jobs/Recruit.Vacancies.Jobs/Triggers/QueueTriggers/CommunicationsHouseKeepingQueueTrigger.cs index 9002fc30b1..52d1cae184 100644 --- a/src/Jobs/Recruit.Vacancies.Jobs/Triggers/QueueTriggers/CommunicationsHouseKeepingQueueTrigger.cs +++ b/src/Jobs/Recruit.Vacancies.Jobs/Triggers/QueueTriggers/CommunicationsHouseKeepingQueueTrigger.cs @@ -18,7 +18,7 @@ public class CommunicationsHouseKeepingQueueTrigger private readonly RecruitWebJobsSystemConfiguration _jobsConfig; private readonly ITimeProvider _timeProvider; private readonly ICommunicationRepository _communicationRepository; - + private const int DefaultStaleByDays = 180; private string JobName => GetType().Name; public CommunicationsHouseKeepingQueueTrigger(ILogger logger, @@ -45,8 +45,8 @@ public async Task CommunicationsHouseKeepingAsync([QueueTrigger(QueueNames.Commu var payload = JsonConvert.DeserializeObject(message); var targetDate = payload?.CreatedByScheduleDate ?? _timeProvider.Today; - - var deleteCommunicationsMessagesBefore180Days = targetDate.AddDays(-180); + + var deleteCommunicationsMessagesBefore180Days = targetDate.AddDays((_jobsConfig.HardDeleteCommunicationMessagesStaleByDays ?? DefaultStaleByDays) * -1); await _communicationRepository.HardDelete(deleteCommunicationsMessagesBefore180Days);