Skip to content

Commit

Permalink
Simplify code in SendReminderEmailsJob to ensure we only send emails …
Browse files Browse the repository at this point in the history
…for current reporting year
  • Loading branch information
jamesgriff committed Sep 30, 2024
1 parent 64694bd commit 637078e
Showing 1 changed file with 3 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,10 @@ private void SendReminderEmailsAction(string runId)

private void SendReminderEmailsForSectorType(SectorTypes sector, string runId, DateTime startTime)
{
var activeReportingYears = GetActiveReportingYears(sector);
foreach (int year in activeReportingYears)
int activeReportingYear = ReportingYearsHelper.GetCurrentReportingYearForSector(sector);
if (IsAfterEarliestReminderForReportingYear(sector, activeReportingYear))
{
if (IsAfterEarliestReminderForReportingYear(sector, year))
{
SendReminderEmailForSectorTypeAndYear(sector, year, runId, startTime);
}
SendReminderEmailForSectorTypeAndYear(sector, activeReportingYear, runId, startTime);
}
}

Expand Down Expand Up @@ -316,12 +313,5 @@ private static List<int> GetReminderEmailDays()
return reminderEmailDays;
}

private static List<int> GetActiveReportingYears(SectorTypes sectorType)
{
return ReportingYearsHelper.GetReportingYears()
.Where(year => GetDeadlineDateForReportingYear(sectorType, year) > VirtualDateTime.Now)
.ToList();
}

}
}

0 comments on commit 637078e

Please sign in to comment.