public async Task ReBuildDashboardAsync(long ukprn)
        {
            var vacancySummariesTask = _vacancyQuery.GetVacanciesByProviderAccountAsync <VacancySummary>(ukprn);

            var applicationReviewStatusCountsTask = _applicationReviewQuery.GetStatusCountsForProviderAsync(ukprn);

            await Task.WhenAll(vacancySummariesTask, applicationReviewStatusCountsTask);

            var vacancySummaries = vacancySummariesTask.Result.ToList();
            var applicationReviewStatusCounts = applicationReviewStatusCountsTask.Result;

            foreach (var summary in vacancySummaries)
            {
                if (summary.VacancyReference.HasValue)
                {
                    summary.AllApplicationsCount = applicationReviewStatusCounts
                                                   .Where(r => r.Id.VacancyReference == summary.VacancyReference.Value)
                                                   .Sum(r => r.Count);

                    summary.NewApplicationsCount = applicationReviewStatusCounts
                                                   .Where(r => r.Id.VacancyReference == summary.VacancyReference.Value &&
                                                          r.Id.Status == ApplicationReviewStatus.New)
                                                   .Sum(r => r.Count);
                }

                await UpdateWithTrainingProgrammeInfo(summary);
            }

            await _queryStoreWriter.UpdateProviderDashboardAsync(ukprn, vacancySummaries.OrderBy(v => v.CreatedDate));

            _logger.LogDebug("Update provider dashboard with {count} summary records for account: {ukprn}", vacancySummaries.Count, ukprn);
        }
예제 #2
0
        public async Task ReBuildDashboardAsync(long ukprn)
        {
            var vacancySummariesTasks     = _vacancySummariesQuery.GetProviderOwnedVacancySummariesByUkprnAsync(ukprn);
            var transferredVacanciesTasks = _vacancySummariesQuery.GetTransferredFromProviderAsync(ukprn);

            await Task.WhenAll(vacancySummariesTasks, transferredVacanciesTasks);

            var vacancySummaries     = vacancySummariesTasks.Result;
            var transferredVacancies = transferredVacanciesTasks.Result.Select(t =>
                                                                               new ProviderDashboardTransferredVacancy
            {
                LegalEntityName = t.LegalEntityName,
                TransferredDate = t.TransferredDate,
                Reason          = t.Reason
            });

            foreach (var summary in vacancySummaries)
            {
                await UpdateWithTrainingProgrammeInfo(summary);
            }

            await _queryStoreWriter.UpdateProviderDashboardAsync(ukprn, vacancySummaries.OrderByDescending(v => v.CreatedDate), transferredVacancies);

            _logger.LogDebug("Update provider dashboard with {count} summary records for account: {ukprn}", vacancySummaries.Count, ukprn);
        }