Skip to content

Commit

Permalink
CON-954: Resolved PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
VasanthaKasirajan3008 committed Aug 26, 2020
1 parent 6f24a7e commit 9f61baa
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public interface ICommunicationRepository
Task UpdateAsync(CommunicationMessage commMsg);
Task<IEnumerable<CommunicationMessage>> GetScheduledMessagesSinceAsync(string requestType, DeliveryFrequency frequency, DateTime from, DateTime to);
Task UpdateScheduledMessagesAsSentAsync(IEnumerable<Guid> msgIds, Guid aggregatedMessageId);
Task HardDelete(DateTime dispatchDateTime);
Task HardDelete(DateTime hardDeleteCommunicationMessagesStaleDateTime);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"disabledJobs" : ["VacancyAnalyticsSummaryGeneratorJob"],
"queryStoreDocumentsStaleByDays" : 90,
"draftVacanciesStaleByDays" : 180,
"referredVacanciesStaleByDays" : 90
"referredVacanciesStaleByDays" : 90,
"hardDeleteCommunicationMessagesStaleByDays" : 180
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ namespace Recruit.Vacancies.Jobs.UnitTests.Triggers.QueueTriggers
{
public class CommunicationsHouseKeepingQueueTriggerTests
{
private const int Days = 180;
private readonly Mock<ILogger<CommunicationsHouseKeepingQueueTrigger>> _loggerMock = new Mock<ILogger<CommunicationsHouseKeepingQueueTrigger>>();
private readonly RecruitWebJobsSystemConfiguration _jobsConfig = new RecruitWebJobsSystemConfiguration() { };
private readonly RecruitWebJobsSystemConfiguration _jobsConfig = new RecruitWebJobsSystemConfiguration() { HardDeleteCommunicationMessagesStaleByDays = Days };
private readonly Mock<ITimeProvider> _timeProviderMock = new Mock<ITimeProvider>();
private readonly Mock<ICommunicationRepository> _communicationRepositoryMock = new Mock<ICommunicationRepository>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<CommunicationsHouseKeepingQueueTrigger> logger,
Expand All @@ -45,8 +45,8 @@ public async Task CommunicationsHouseKeepingAsync([QueueTrigger(QueueNames.Commu
var payload = JsonConvert.DeserializeObject<CommunicationsHouseKeepingQueueMessage>(message);

var targetDate = payload?.CreatedByScheduleDate ?? _timeProvider.Today;

var deleteCommunicationsMessagesBefore180Days = targetDate.AddDays(-180);
var deleteCommunicationsMessagesBefore180Days = targetDate.AddDays((_jobsConfig.HardDeleteCommunicationMessagesStaleByDays ?? DefaultStaleByDays) * -1);

await _communicationRepository.HardDelete(deleteCommunicationsMessagesBefore180Days);

Expand Down

0 comments on commit 9f61baa

Please sign in to comment.