private Task <TrainingProviders> GetProviders() { return(_cache.CacheAsideAsync( CacheKeys.TrainingProviders, _timeProvider.NextDay6am, () => _referenceDataReader.GetReferenceData <TrainingProviders>())); }
public async Task <IList <string> > GetBlockedEmployerAccountIdsAsync() { var blockedEmployers = await _referenceDataReader.GetReferenceData <BlockedEmployers>(); _logger.LogInformation($"Found {blockedEmployers.EmployerAccountIds.Count()} blocked employers."); return(blockedEmployers.EmployerAccountIds.Select(s => s.ToUpper()).ToList()); }
public async Task <IList <string> > GetQualificationsAsync() { return(await _cache.CacheAsideAsync(CacheKeys.Qualifications, _timeProvider.NextDay, async() => { var data = await _referenceDataReader.GetReferenceData <Qualifications>(); return data.QualificationTypes; })); }
private async Task CreateClosedVacancyProjection(Guid vacancyId) { var vacancyTask = _repository.GetVacancyAsync(vacancyId); var programmeTask = _referenceDataReader.GetReferenceData <ApprenticeshipProgrammes>(); await Task.WhenAll(vacancyTask, programmeTask); var vacancy = vacancyTask.Result; var programme = programmeTask.Result.Data.Single(p => p.Id == vacancy.ProgrammeId); await _queryStore.UpdateClosedVacancyAsync(vacancy.ToVacancyProjectionBase <ClosedVacancy>(programme, () => QueryViewType.ClosedVacancy.GetIdValue(vacancy.VacancyReference.ToString()))); }
public async Task Handle(VacancyPublishedEvent notification, CancellationToken cancellationToken) { var vacancyTask = _repository.GetVacancyAsync(notification.VacancyId); var programmeTask = _referenceDataReader.GetReferenceData <ApprenticeshipProgrammes>(); await Task.WhenAll(vacancyTask, programmeTask); var vacancy = vacancyTask.Result; var programme = programmeTask.Result.Data.Single(p => p.Id == vacancy.ProgrammeId); var liveVacancy = vacancy.ToVacancyProjectionBase <LiveVacancy>(programme, () => QueryViewType.LiveVacancy.GetIdValue(vacancy.VacancyReference.ToString()), _timeProvider); await _queryStoreWriter.UpdateLiveVacancyAsync(liveVacancy); }
public async Task <List <DateTime> > GetBankHolidaysAsync() { return(await _cache.CacheAsideAsync(CacheKeys.BankHolidays, _timeProvider.NextDay, async() => { var bankHolidayReferenceData = await _referenceDataReader.GetReferenceData <BankHolidays>(); return bankHolidayReferenceData.Data.EnglandAndWales.Events .Select(e => DateTime.Parse(e.Date)) .ToList(); })); }
private async Task <bool> HasBankHolidayDataChanged(BankHolidays bankHolidaysFromApi) { var bankHolidaysFromDb = await _referenceDataReader.GetReferenceData <BankHolidays>(); if (bankHolidaysFromDb == null) { return(true); } var bankHolidaysFromApiJson = JsonConvert.SerializeObject(bankHolidaysFromApi.Data); var bankHolidaysFromDbJson = JsonConvert.SerializeObject(bankHolidaysFromDb.Data); var areEqual = JToken.DeepEquals(bankHolidaysFromApiJson, bankHolidaysFromDbJson); return(!areEqual); }
public async Task <IEnumerable <string> > GetProfanityListAsync() { return(await _cache.CacheAsideAsync(CacheKeys.Profanities, _timeProvider.NextDay, async() => { _logger.LogInformation("Attempting to retrieve profanity list from reference data."); var result = await _referenceDataReader.GetReferenceData <ProfanityList>(); if (result != null) { return result.Profanities; } _logger.LogWarning("Unable to retrieve reference data for profanity list."); return new List <string>(); })); }
public async Task <List <string> > GetCandidateSkillsAsync() { return(await _cache.CacheAsideAsync(CacheKeys.Skills, _timeProvider.NextDay, async() => { _logger.LogInformation("Attempting to retrieve candidate skills from reference data."); var result = await _referenceDataReader.GetReferenceData <CandidateSkills>(); if (result != null) { return result.Skills; } _logger.LogWarning("Unable to retrieve reference data for candidate skills."); return new List <string>(); })); }
public async Task ReGeneratePublishedVacanciesAsync() { var liveVacancyIdsTask = _vacancyQuery.GetVacanciesByStatusAsync <VacancyIdentifier>(VacancyStatus.Live); var closedVacancyIdsTask = _vacancyQuery.GetVacanciesByStatusAsync <VacancyIdentifier>(VacancyStatus.Closed); var programmesTask = _referenceDataReader.GetReferenceData <ApprenticeshipProgrammes>(); await Task.WhenAll(liveVacancyIdsTask, programmesTask, closedVacancyIdsTask); var liveVacancyIds = liveVacancyIdsTask.Result.Select(v => v.Id).ToList(); var closedVacancyIds = closedVacancyIdsTask.Result.Select(v => v.Id).ToList(); var programmes = programmesTask.Result.Data; var regenerateLiveVacanciesViewsTask = RegenerateLiveVacancies(liveVacancyIds, programmes); var regenerateClosedVacanciesViewsTask = RegenerateClosedVacancies(closedVacancyIds, programmes); await Task.WhenAll(regenerateClosedVacanciesViewsTask, regenerateLiveVacanciesViewsTask); }
private async Task CreateClosedVacancyProjection(Guid vacancyId) { var vacancyTask = _repository.GetVacancyAsync(vacancyId); var programmeTask = _referenceDataReader.GetReferenceData <ApprenticeshipProgrammes>(); await Task.WhenAll(vacancyTask, programmeTask); var vacancy = vacancyTask.Result; var programme = programmeTask.Result.Data.Single(p => p.Id == vacancy.ProgrammeId); await _queryStore.UpdateClosedVacancyAsync(vacancy.ToVacancyProjectionBase <ClosedVacancy>(programme, () => QueryViewType.ClosedVacancy.GetIdValue(vacancy.VacancyReference.ToString()), _timeProvider)); if (vacancy.ClosureReason == ClosureReason.WithdrawnByQa) { _logger.LogInformation($"Queuing up withdrawn notification message for vacancy {vacancy.VacancyReference}"); var communicationRequest = GetVacancyWithdrawnByQaCommunicationRequest(vacancy.VacancyReference.Value); await _communicationQueueService.AddMessageAsync(communicationRequest); } }
private async Task ValidateList(List <ApprenticeshipProgramme> apprenticeshipProgrammesFromApi) { var apprenticeshipProgrammesFromDb = await _referenceDataReader.GetReferenceData <ApprenticeshipProgrammes>(); if (apprenticeshipProgrammesFromDb == null) { return; } var apiCount = apprenticeshipProgrammesFromApi.Count; var dbCount = apprenticeshipProgrammesFromDb.Data.Count(); var difference = Math.Abs(apiCount - dbCount); double percent = (double)(difference * 100) / apiCount; if (percent > AcceptablePercentage) { _logger.LogWarning("There is a difference of more than 10% between the existing ApprenticeshipProgrammes and the " + $"new ApprenticeshipProgramme, apprenticeshipProgrammesFromApi:{apiCount} and " + $"apprenticeshipProgrammesFromDb:{dbCount}"); } }
private Task <ApprenticeshipProgrammes> GetApprenticeshipProgrammesAsync() { return(_cache.CacheAsideAsync(CacheKeys.ApprenticeshipProgrammes, _timeProvider.NextDay6am, () => _referenceDataReader.GetReferenceData <ApprenticeshipProgrammes>())); }
public Task <Qualifications> GetCandidateQualificationsAsync() { return(_referenceDataReader.GetReferenceData <Qualifications>()); }