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

FAI-2141 OtherAddresses field added to the LIVE VACANCY for both RAA & NHS Jobs #1838

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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<Address> OtherAddresses { get; set; } = [];
public string? EmployerName { get; set; }
public long? Ukprn { get; set; }
public string? ProviderName { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,16 @@
using SFA.DAS.SharedOuterApi.Interfaces;

namespace SFA.DAS.FindApprenticeshipJobs.Application.Queries;
public class GetLiveVacanciesQueryHandler : IRequestHandler<GetLiveVacanciesQuery, GetLiveVacanciesQueryResult>
public class GetLiveVacanciesQueryHandler(
IRecruitApiClient<RecruitApiConfiguration> recruitApiClient,
ILiveVacancyMapper liveVacancyMapper,
ICourseService courseService)
: IRequestHandler<GetLiveVacanciesQuery, GetLiveVacanciesQueryResult>
{
private readonly IRecruitApiClient<RecruitApiConfiguration> _recruitApiClient;
private readonly ILiveVacancyMapper _liveVacancyMapper;
private readonly ICourseService _courseService;

public GetLiveVacanciesQueryHandler(IRecruitApiClient<RecruitApiConfiguration> recruitApiClient, ILiveVacancyMapper liveVacancyMapper, ICourseService courseService)
{
_recruitApiClient = recruitApiClient;
_courseService = courseService;
_liveVacancyMapper = liveVacancyMapper;
}

public async Task<GetLiveVacanciesQueryResult> Handle(GetLiveVacanciesQuery request, CancellationToken cancellationToken)
{
var vacanciesResponseTask = _recruitApiClient.GetWithResponseCode<GetLiveVacanciesApiResponse>(new GetLiveVacanciesApiRequest(request.PageNumber, request.PageSize, request.ClosingDate));
var standardsTask = _courseService.GetActiveStandards<GetStandardsListResponse>(nameof(GetStandardsListResponse));
var vacanciesResponseTask = recruitApiClient.GetWithResponseCode<GetLiveVacanciesApiResponse>(new GetLiveVacanciesApiRequest(request.PageNumber, request.PageSize, request.ClosingDate));
var standardsTask = courseService.GetActiveStandards<GetStandardsListResponse>(nameof(GetStandardsListResponse));

await Task.WhenAll(vacanciesResponseTask, standardsTask);

Expand All @@ -38,7 +31,7 @@ public async Task<GetLiveVacanciesQueryResult> 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))
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ public class GetLiveVacanciesQueryResult
public int TotalLiveVacanciesReturned { get; set; }
public int TotalLiveVacancies { get; set; }
public int TotalPages { get; set; }
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class LiveVacancy
public int NumberOfPositions { get; set; }
public string? ApprenticeshipTitle { get; set; }
public string? Description { get; set; }
public List<Address> OtherAddresses { get; set; } = [];
public Address? Address { get; set; }
public string? EmployerName { get; set; }
public string ProviderName { get; set; } = null!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class LiveVacancy
public string? ProviderContactPhone { get; set; }
public string? EmployerDescription { get; set; }
public Address? EmployerLocation { get; set; }
public List<Address> OtherAddresses { get; set; } = [];
public string? EmployerName { get; set; }
public string? EmployerWebsiteUrl { get; set; }
public bool IsAnonymous { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -132,6 +133,7 @@ public Application.Shared.LiveVacancy Map(GetNhsJobApiDetailResponse source, Get
},
Qualifications = [],
Skills = [],
OtherAddresses = [],
SearchTags = "NHS National Health Service Health Medical Hospital",
};
}
Expand Down