Skip to content

Commit

Permalink
Merge pull request #797 from bcgov/hotfix
Browse files Browse the repository at this point in the history
fix: takedown confirmation not being processed
  • Loading branch information
ychung-mot authored Nov 19, 2024
2 parents 805ad79 + f9df47b commit 077c3b7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 5 deletions.
8 changes: 5 additions & 3 deletions server/StrDss.Data/Repositories/UploadDeliveryRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public interface IUploadDeliveryRepository
Task AddUploadDeliveryAsync(DssUploadDelivery upload);
Task<DssUploadDelivery?> GetUploadToProcessAsync(string reportType);
Task<DssUploadDelivery?> GetNonTakedownUploadToProcessAsync();
Task<DssUploadDelivery[]> GetUploadsToProcessAsync(string reportType);
Task<DssUploadDelivery[]> GetUploadsToProcessForOneYearAsync(string reportType);
Task<DssUploadDelivery?> GetRentalListingUploadWithErrors(long uploadId);
Task<DssUploadLine?> GetUploadLineAsync(long uploadId, string orgCd, string listingId);
Task<List<UploadLineToProcess>> GetUploadLinesToProcessAsync(long uploadId);
Expand Down Expand Up @@ -65,11 +65,13 @@ public async Task<bool> IsDuplicateRentalReportUploadAsnyc(DateOnly? periodYm, l
.FirstOrDefaultAsync();
}

public async Task<DssUploadDelivery[]> GetUploadsToProcessAsync(string reportType)
public async Task<DssUploadDelivery[]> 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.
Expand Down
2 changes: 1 addition & 1 deletion server/StrDss.Service/Hangfire/HangfireJobs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
13 changes: 12 additions & 1 deletion server/StrDss.Service/TakedownConfirmationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace StrDss.Service
public interface ITakedownConfirmationService
{
Task ProcessTakedownConfirmationUploadAsync(DssUploadDelivery upload);
Task ProcessTakedownConfirmationUploadsAsync();
}
public class TakedownConfirmationService : ServiceBase, ITakedownConfirmationService
{
Expand All @@ -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;

Expand Down

0 comments on commit 077c3b7

Please sign in to comment.