From f9df47b98f93db26ab818876cce93317529dd247 Mon Sep 17 00:00:00 2001 From: ychung-mot Date: Tue, 19 Nov 2024 09:14:10 -0800 Subject: [PATCH] fix: takedown confirmation not being processed --- .../Repositories/UploadDeliveryRepository.cs | 8 +++++--- server/StrDss.Service/Hangfire/HangfireJobs.cs | 2 +- .../StrDss.Service/TakedownConfirmationService.cs | 13 ++++++++++++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/server/StrDss.Data/Repositories/UploadDeliveryRepository.cs b/server/StrDss.Data/Repositories/UploadDeliveryRepository.cs index 2736c260..605e68ac 100644 --- a/server/StrDss.Data/Repositories/UploadDeliveryRepository.cs +++ b/server/StrDss.Data/Repositories/UploadDeliveryRepository.cs @@ -14,7 +14,7 @@ public interface IUploadDeliveryRepository Task AddUploadDeliveryAsync(DssUploadDelivery upload); Task GetUploadToProcessAsync(string reportType); Task GetNonTakedownUploadToProcessAsync(); - Task GetUploadsToProcessAsync(string reportType); + Task GetUploadsToProcessForOneYearAsync(string reportType); Task GetRentalListingUploadWithErrors(long uploadId); Task GetUploadLineAsync(long uploadId, string orgCd, string listingId); Task> GetUploadLinesToProcessAsync(long uploadId); @@ -65,11 +65,13 @@ public async Task IsDuplicateRentalReportUploadAsnyc(DateOnly? periodYm, l .FirstOrDefaultAsync(); } - public async Task GetUploadsToProcessAsync(string reportType) + public async Task GetUploadsToProcessForOneYearAsync(string reportType) { + var dateFrom = DateTime.UtcNow.AddMonths(-12); + return await _dbSet .Include(x => x.ProvidingOrganization) - .Where(x => x.DssUploadLines.Any(line => !line.IsProcessed) && x.UploadDeliveryType == reportType) + .Where(x => x.DssUploadLines.Any(line => !line.IsProcessed) && x.UploadDeliveryType == reportType && x.UpdDtm >= dateFrom) .OrderBy(x => x.ProvidingOrganizationId) .ThenBy(x => x.ReportPeriodYm) .ThenBy(x => x.UpdDtm) //Users can upload the same listing multiple times. The processing of these listings follows a first-come, first-served approach. diff --git a/server/StrDss.Service/Hangfire/HangfireJobs.cs b/server/StrDss.Service/Hangfire/HangfireJobs.cs index 80a9e4bd..69ad4811 100644 --- a/server/StrDss.Service/Hangfire/HangfireJobs.cs +++ b/server/StrDss.Service/Hangfire/HangfireJobs.cs @@ -67,7 +67,7 @@ public async Task ProcessUpload() await _linstingReportService.ProcessRentalReportUploadAsync(upload); break; case UploadDeliveryTypes.TakedownData: - await _tdcService.ProcessTakedownConfirmationUploadAsync(upload); + await _tdcService.ProcessTakedownConfirmationUploadsAsync(); break; case UploadDeliveryTypes.LicenceData: await _bizLicService.ProcessBizLicenceUploadMainAsync(upload); diff --git a/server/StrDss.Service/TakedownConfirmationService.cs b/server/StrDss.Service/TakedownConfirmationService.cs index f92035fb..d5147326 100644 --- a/server/StrDss.Service/TakedownConfirmationService.cs +++ b/server/StrDss.Service/TakedownConfirmationService.cs @@ -15,6 +15,7 @@ namespace StrDss.Service public interface ITakedownConfirmationService { Task ProcessTakedownConfirmationUploadAsync(DssUploadDelivery upload); + Task ProcessTakedownConfirmationUploadsAsync(); } public class TakedownConfirmationService : ServiceBase, ITakedownConfirmationService { @@ -34,11 +35,21 @@ public TakedownConfirmationService( _orgRepo = orgRepo; } + public async Task ProcessTakedownConfirmationUploadsAsync() + { + var uploads = await _uploadRepo.GetUploadsToProcessForOneYearAsync(UploadDeliveryTypes.TakedownData); + + foreach (var upload in uploads) + { + await ProcessTakedownConfirmationUploadAsync(upload); + } + } + public async Task ProcessTakedownConfirmationUploadAsync(DssUploadDelivery upload) { var processStopwatch = Stopwatch.StartNew(); - _logger.LogInformation($"Processing Takedown Confirmation {upload.ProvidingOrganizationId} - {upload.ReportPeriodYm} - {upload.ProvidingOrganization.OrganizationNm}"); + _logger.LogInformation($"Processing Takedown Confirmation ({upload.UploadDeliveryId}) {upload.ProvidingOrganization.OrganizationNm} - {upload.ReportPeriodYm}"); var count = 0;