From 0df9efd3fdcaa5038df439b344d1d99ba6392d30 Mon Sep 17 00:00:00 2001 From: Balaji Jambulingam Date: Tue, 10 Dec 2024 16:02:57 +0000 Subject: [PATCH 1/2] OtherAddresses field added to the LIVE VACANCY for both RAA & NHS Jobs Story: https://skillsfundingagency.atlassian.net/browse/FAI-2141 --- ...MediatorResponseToGetLiveVacanciesModel.cs | 1 - .../Models/GetLiveVacanciesApiResponse.cs | 2 ++ .../Services/WhenMappingLiveVacancy.cs | 3 +++ .../Queries/GetLiveVacanciesQueryHandler.cs | 23 +++++++------------ .../Queries/GetLiveVacanciesQueryResult.cs | 3 +-- .../Application/Shared/Address.cs | 14 +++++++++++ .../Application/Shared/LiveVacancy.cs | 1 + .../Responses/GetLiveVacanciesApiResponse.cs | 5 +++- .../Services/LiveVacancyMapper.cs | 4 +++- 9 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api.UnitTests/Models/WhenMappingFromMediatorResponseToGetLiveVacanciesModel.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api.UnitTests/Models/WhenMappingFromMediatorResponseToGetLiveVacanciesModel.cs index 2c317c65ef..b83dc87dc2 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api.UnitTests/Models/WhenMappingFromMediatorResponseToGetLiveVacanciesModel.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api.UnitTests/Models/WhenMappingFromMediatorResponseToGetLiveVacanciesModel.cs @@ -36,6 +36,5 @@ public void Then_The_Fields_Are_Mapped_For_Nhs_Vacancies(GetNhsJobsQueryResult s actual.TotalLiveVacanciesReturned.Should().Be(source.NhsVacancies.Count); actual.PageSize.Should().Be(source.NhsVacancies.Count); actual.TotalLiveVacancies.Should().Be(source.NhsVacancies.Count); - } } diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api/Models/GetLiveVacanciesApiResponse.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api/Models/GetLiveVacanciesApiResponse.cs index 2714cf931f..2026e610ca 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api/Models/GetLiveVacanciesApiResponse.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.Api/Models/GetLiveVacanciesApiResponse.cs @@ -51,6 +51,7 @@ public static implicit operator LiveVacancy(Application.Shared.LiveVacancy sourc Route = source.Route, Description = source.Description, Address = source.Address == null ? null : (Address)source.Address, + OtherAddresses = source.OtherAddresses is {Count: > 0} ? source.OtherAddresses.Select(add => (Address)add).ToList() : [], ClosingDate = source.ClosingDate, StartDate = source.StartDate, PostedDate = source.PostedDate, @@ -118,6 +119,7 @@ public static implicit operator LiveVacancy(Application.Shared.LiveVacancy sourc public string ApprenticeshipTitle { get; set; } public string? Description { get; set; } public Address? Address { get; set; } + public List
OtherAddresses { get; set; } = []; public string? EmployerName { get; set; } public long? Ukprn { get; set; } public string? ProviderName { get; set; } diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Services/WhenMappingLiveVacancy.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Services/WhenMappingLiveVacancy.cs index 38f5686706..c38539ee6e 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Services/WhenMappingLiveVacancy.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs.UnitTests/Services/WhenMappingLiveVacancy.cs @@ -65,6 +65,7 @@ public void Then_The_Nhs_Vacancy_Is_Mapped(GetNhsJobApiDetailResponse source, Li actual.Route.Should().Be(route.Name); actual.RouteCode.Should().Be(route.Id); actual.SearchTags.Should().Be("NHS National Health Service Health Medical Hospital"); + actual.OtherAddresses.Should().BeEmpty(); } private static void AssertResponse(FindApprenticeshipJobs.Application.Shared.LiveVacancy actual, LiveVacancy source, GetStandardsListResponse standardsListResponse) @@ -140,6 +141,8 @@ private static void AssertResponse(FindApprenticeshipJobs.Application.Shared.Liv Latitude = source.EmployerLocation?.Latitude ?? 0, Longitude = source.EmployerLocation?.Longitude ?? 0, }, + source.OtherAddresses, + source.AdditionalQuestion1, source.AdditionalQuestion2, source.AdditionalTrainingDescription diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/GetLiveVacanciesQueryHandler.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/GetLiveVacanciesQueryHandler.cs index 8b5246eee3..be0597585b 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/GetLiveVacanciesQueryHandler.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/GetLiveVacanciesQueryHandler.cs @@ -6,23 +6,16 @@ using SFA.DAS.SharedOuterApi.Interfaces; namespace SFA.DAS.FindApprenticeshipJobs.Application.Queries; -public class GetLiveVacanciesQueryHandler : IRequestHandler +public class GetLiveVacanciesQueryHandler( + IRecruitApiClient recruitApiClient, + ILiveVacancyMapper liveVacancyMapper, + ICourseService courseService) + : IRequestHandler { - private readonly IRecruitApiClient _recruitApiClient; - private readonly ILiveVacancyMapper _liveVacancyMapper; - private readonly ICourseService _courseService; - - public GetLiveVacanciesQueryHandler(IRecruitApiClient recruitApiClient, ILiveVacancyMapper liveVacancyMapper, ICourseService courseService) - { - _recruitApiClient = recruitApiClient; - _courseService = courseService; - _liveVacancyMapper = liveVacancyMapper; - } - public async Task Handle(GetLiveVacanciesQuery request, CancellationToken cancellationToken) { - var vacanciesResponseTask = _recruitApiClient.GetWithResponseCode(new GetLiveVacanciesApiRequest(request.PageNumber, request.PageSize, request.ClosingDate)); - var standardsTask = _courseService.GetActiveStandards(nameof(GetStandardsListResponse)); + var vacanciesResponseTask = recruitApiClient.GetWithResponseCode(new GetLiveVacanciesApiRequest(request.PageNumber, request.PageSize, request.ClosingDate)); + var standardsTask = courseService.GetActiveStandards(nameof(GetStandardsListResponse)); await Task.WhenAll(vacanciesResponseTask, standardsTask); @@ -38,7 +31,7 @@ public async Task Handle(GetLiveVacanciesQuery requ TotalLiveVacanciesReturned = vacanciesResponse.Body.TotalLiveVacanciesReturned, TotalLiveVacancies = vacanciesResponse.Body.TotalLiveVacancies, TotalPages = vacanciesResponse.Body.TotalPages, - Vacancies = vacanciesResponse.Body.Vacancies.Select(x => _liveVacancyMapper.Map(x, standards)) + Vacancies = vacanciesResponse.Body.Vacancies.Select(x => liveVacancyMapper.Map(x, standards)) }; } diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/GetLiveVacanciesQueryResult.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/GetLiveVacanciesQueryResult.cs index e2cd2ba084..44ec78f642 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/GetLiveVacanciesQueryResult.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Queries/GetLiveVacanciesQueryResult.cs @@ -10,5 +10,4 @@ public class GetLiveVacanciesQueryResult public int TotalLiveVacanciesReturned { get; set; } public int TotalLiveVacancies { get; set; } public int TotalPages { get; set; } -} - +} \ No newline at end of file diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Shared/Address.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Shared/Address.cs index 535758c574..63ada570bb 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Shared/Address.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Shared/Address.cs @@ -9,4 +9,18 @@ public class Address public string? Postcode { get; set; } public double Latitude { get; set; } public double Longitude { get; set; } + + public static implicit operator Address(InnerApi.Responses.Address source) + { + return new Address + { + AddressLine1 = source.AddressLine1, + AddressLine2 = source.AddressLine2, + AddressLine3 = source.AddressLine3, + AddressLine4 = source.AddressLine4, + Postcode = source.Postcode, + Latitude = source.Latitude, + Longitude = source.Longitude + }; + } } \ No newline at end of file diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Shared/LiveVacancy.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Shared/LiveVacancy.cs index 838a797281..f5c814b9d0 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Shared/LiveVacancy.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Application/Shared/LiveVacancy.cs @@ -9,6 +9,7 @@ public class LiveVacancy public int NumberOfPositions { get; set; } public string? ApprenticeshipTitle { get; set; } public string? Description { get; set; } + public List
OtherAddresses { get; set; } = []; public Address? Address { get; set; } public string? EmployerName { get; set; } public string ProviderName { get; set; } = null!; diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetLiveVacanciesApiResponse.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetLiveVacanciesApiResponse.cs index 0749340cf8..995f1b3e7d 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetLiveVacanciesApiResponse.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetLiveVacanciesApiResponse.cs @@ -1,4 +1,6 @@ -namespace SFA.DAS.FindApprenticeshipJobs.InnerApi.Responses; +using Microsoft.Extensions.ObjectPool; + +namespace SFA.DAS.FindApprenticeshipJobs.InnerApi.Responses; public class GetLiveVacanciesApiResponse { public IEnumerable Vacancies { get; set; } = null!; @@ -23,6 +25,7 @@ public class LiveVacancy public string? ProviderContactPhone { get; set; } public string? EmployerDescription { get; set; } public Address? EmployerLocation { get; set; } + public List
OtherAddresses { get; set; } = []; public string? EmployerName { get; set; } public string? EmployerWebsiteUrl { get; set; } public bool IsAnonymous { get; set; } diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Services/LiveVacancyMapper.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Services/LiveVacancyMapper.cs index 26f269edeb..fdfb2008f1 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Services/LiveVacancyMapper.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/Services/LiveVacancyMapper.cs @@ -75,7 +75,7 @@ public Application.Shared.LiveVacancy Map(LiveVacancy source, GetStandardsListRe ProviderContactPhone = source.ProviderContactPhone, EmployerDescription = source.EmployerDescription, EmployerWebsiteUrl = source.EmployerWebsiteUrl, - Address = new Application.Shared.Address + Address = new Address { AddressLine1 = source.EmployerLocation?.AddressLine1, AddressLine2 = source.EmployerLocation?.AddressLine2, @@ -85,6 +85,7 @@ public Application.Shared.LiveVacancy Map(LiveVacancy source, GetStandardsListRe Latitude = source.EmployerLocation?.Latitude ?? 0, Longitude = source.EmployerLocation?.Longitude ?? 0, }, + OtherAddresses = source.OtherAddresses is {Count: > 0} ? source.OtherAddresses.Select(add => (Address)add).ToList() : [], Duration = source.Wage.Duration, DurationUnit = source.Wage.DurationUnit, ThingsToConsider = source.ThingsToConsider, @@ -132,6 +133,7 @@ public Application.Shared.LiveVacancy Map(GetNhsJobApiDetailResponse source, Get }, Qualifications = [], Skills = [], + OtherAddresses = [], SearchTags = "NHS National Health Service Health Medical Hospital", }; } From 42f1049b465298acd8eadb88463f27d2333019c4 Mon Sep 17 00:00:00 2001 From: Balaji Jambulingam Date: Tue, 10 Dec 2024 16:09:54 +0000 Subject: [PATCH 2/2] Minor Clean-up --- .../InnerApi/Responses/GetLiveVacanciesApiResponse.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetLiveVacanciesApiResponse.cs b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetLiveVacanciesApiResponse.cs index 995f1b3e7d..4163f90cdd 100644 --- a/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetLiveVacanciesApiResponse.cs +++ b/src/FindApprenticeshipJobs/SFA.DAS.FindApprenticeshipJobs/InnerApi/Responses/GetLiveVacanciesApiResponse.cs @@ -1,6 +1,4 @@ -using Microsoft.Extensions.ObjectPool; - -namespace SFA.DAS.FindApprenticeshipJobs.InnerApi.Responses; +namespace SFA.DAS.FindApprenticeshipJobs.InnerApi.Responses; public class GetLiveVacanciesApiResponse { public IEnumerable Vacancies { get; set; } = null!;