Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: takedown confirmation not being processed #797

Merged
merged 1 commit into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading