Skip to content
This repository has been archived by the owner on Jul 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request #103 from SkillsFundingAgency/FC-516_Apprenticeshi…
Browse files Browse the repository at this point in the history
…p_Search

FC-516 / FC-517 / FC-554 Apprenticeship Search
  • Loading branch information
SimonHeathESFA committed May 10, 2019
2 parents db32841 + 358b1d0 commit 775c164
Show file tree
Hide file tree
Showing 66 changed files with 2,481 additions and 332 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Net.Http;
using System.Threading.Tasks;
using SFA.DAS.Apprenticeships.Api.Types;
using SFA.DAS.Apprenticeships.Api.Types.enums;

namespace SFA.DAS.Apprenticeships.Api.Client
{
Expand Down Expand Up @@ -42,5 +43,13 @@ public async Task<IEnumerable<ApprenticeshipSearchResultsItem>> SearchAsync(stri
return await RequestAndDeserialiseAsync<IEnumerable<ApprenticeshipSearchResultsItem>>(request);
}
}
}

private string GetLevelsAsCommaSeparatedString(IEnumerable<int> levels)
{
if (levels == null)
return null;

return string.Join("%2C%20", levels);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,7 @@ public class ApprenticeshipSearchResultsItem
public DateTime? EffectiveFrom { get; set; }

public DateTime? EffectiveTo { get; set; }
}

public DateTime? LastDateForNewStarts { get; set; }
}
}
15 changes: 15 additions & 0 deletions src/SFA.DAS.Apprenticeships.Api.Types/V3/Address.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace SFA.DAS.Apprenticeships.Api.Types.V3
{
public class Address
{
public string Primary { get; set; }

public string Secondary { get; set; }

public string Street { get; set; }

public string Town { get; set; }

public string Postcode { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System.Collections.Generic;

namespace SFA.DAS.Apprenticeships.Api.Types.V3
{
public sealed class ApprenticeshipSearchResults : PagedResults<ApprenticeshipSearchResultsItem>
{
public Dictionary<int, long?> LevelAggregation { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;

namespace SFA.DAS.Apprenticeships.Api.Types.V3
{
public class ApprenticeshipSearchResultsItem
{
public string Id { get; set; }
public ApprenticeshipTrainingType ProgrammeType { get; set; }
public string Title { get; set; }
public List<string> JobRoles { get; set; }
public List<string> Keywords { get; set; }
public int Level { get; set; }
public bool Published { get; set; }
public int Duration { get; set; }
public DateTime? EffectiveFrom { get; set; }
public DateTime? EffectiveTo { get; set; }
public DateTime? LastDateForNewStarts { get; set; }

// Should be removed when frameworks are finally gone.
public string FrameworkName { get; set; }
public string PathwayName { get; set; }
}
}
14 changes: 14 additions & 0 deletions src/SFA.DAS.Apprenticeships.Api.Types/V3/DeliveryMode.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Runtime.Serialization;

namespace SFA.DAS.Apprenticeships.Api.Types.V3
{
public enum DeliveryMode
{
[EnumMember(Value = "DayRelease")]
DayRelease,
[EnumMember(Value = "BlockRelease")]
BlockRelease,
[EnumMember(Value = "100PercentEmployer")]
HundredPercentEmployer
}
}
14 changes: 14 additions & 0 deletions src/SFA.DAS.Apprenticeships.Api.Types/V3/Feedback.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System.Collections.Generic;

namespace SFA.DAS.Apprenticeships.Api.Types.V3
{
public class Feedback
{
public ICollection<ProviderAttribute> Strengths { get; set; }
public ICollection<ProviderAttribute> Weaknesses { get; set; }
public int ExcellentFeedbackCount { get; set; }
public int GoodFeedbackCount { get; set; }
public int PoorFeedbackCount { get; set; }
public int VeryPoorFeedbackCount { get; set; }
}
}
17 changes: 17 additions & 0 deletions src/SFA.DAS.Apprenticeships.Api.Types/V3/PagedResults.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace SFA.DAS.Apprenticeships.Api.Types.V3
{
public abstract class PagedResults<T> where T : class
{
public long TotalResults { get; set; }

public int PageSize { get; set; }

public int PageNumber { get; set; }

public IEnumerable<T> Results { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System.Collections.Generic;

namespace SFA.DAS.Apprenticeships.Api.Types.V3
{
public class ProviderApprenticeshipLocationSearchResult : PagedResults<ProviderSearchResultItem>
{
public Dictionary<string, long?> TrainingOptionsAggregation { get; set; }

public Dictionary<string, long?> NationalProvidersAggregation { get; set; }
}
}
9 changes: 9 additions & 0 deletions src/SFA.DAS.Apprenticeships.Api.Types/V3/ProviderAttribute.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SFA.DAS.Apprenticeships.Api.Types.V3
{
public class ProviderAttribute
{
public string Name { get; set; }

public int Count { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System.Collections.Generic;

namespace SFA.DAS.Apprenticeships.Api.Types.V3
{
public class ProviderSearchResultItem
{
public int Ukprn { get; set; }

public TrainingLocation Location { get; set; }

public string ProviderName { get; set; }

public double? OverallAchievementRate { get; set; }

public bool NationalProvider { get; set; }

public List<string> DeliveryModes { get; set; }

public double Distance { get; set; }

public double? EmployerSatisfaction { get; set; }

public double? LearnerSatisfaction { get; set; }

public double? NationalOverallAchievementRate { get; set; }

public string OverallCohort { get; set; }

public bool HasNonLevyContract { get; set; }

public bool IsLevyPayerOnly { get; set; }

public bool CurrentlyNotStartingNewApprentices { get; set; }
}
}
11 changes: 11 additions & 0 deletions src/SFA.DAS.Apprenticeships.Api.Types/V3/TrainingLocation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace SFA.DAS.Apprenticeships.Api.Types.V3
{
public class TrainingLocation
{
public int LocationId { get; set; }

public string LocationName { get; set; }

public Address Address { get; set; }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace SFA.DAS.Apprenticeships.Api.Types.enums
{
public enum ApprenticeshipResultsOrder : int
{
BestMatch = 1,
LevelDescending = 2,
LevelAscending = 3
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<Setting name="AssessmentOrgsIndexAlias" />
<Setting name="FrameworksExpiredRequired" />
<Setting name="StandardsExpiredRequired" />
<Setting name="AllowedCorsUrls" />
<Setting name="APPINSIGHTS_INSTRUMENTATIONKEY"/>
</ConfigurationSettings>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<Setting name="AssessmentOrgsIndexAlias" />
<Setting name="FrameworksExpiredRequired" />
<Setting name="StandardsExpiredRequired" />
<Setting name="AllowedCorsUrls" />
<Setting name="APPINSIGHTS_INSTRUMENTATIONKEY"/>
</ConfigurationSettings>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" loadBalancer="das-fatapi-ilb"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<Setting name="AssessmentOrgsIndexAlias" value="__AssessmentOrgsIndexAlias__" />
<Setting name="FrameworksExpiredRequired" value="__FrameworksExpiredRequired__"/>
<Setting name="StandardsExpiredRequired" value="__StandardsExpiredRequired__"/>
<Setting name="AllowedCorsUrls" value="__AllowedCorsUrls__"/>
<Setting name="APPINSIGHTS_INSTRUMENTATIONKEY" value="__InstrumentationKey__"/>
</ConfigurationSettings>
<Certificates>
<Certificate name="WebSslCert" thumbprint="D4B7EBCE1013CBB10A6DD74D1A20E2C9A69107A2" thumbprintAlgorithm="sha1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<Setting name="AssessmentOrgsIndexAlias" value="localassessmentorgsindexalias" />
<Setting name="FrameworksExpiredRequired" value=""/>
<Setting name="StandardsExpiredRequired" value="73"/>
<Setting name="AllowedCorsUrls" value=""/>
<Setting name="APPINSIGHTS_INSTRUMENTATIONKEY" value=""/>
</ConfigurationSettings>
<Certificates>
<Certificate name="WebSslCert" thumbprint="7A1BC8263B7CBAA2B355934D0BB8031B469C1AE1" thumbprintAlgorithm="sha1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<Setting name="AssessmentOrgsIndexAlias" value="__AssessmentOrgsIndexAlias__" />
<Setting name="FrameworksExpiredRequired" value="__FrameworksExpiredRequired__"/>
<Setting name="StandardsExpiredRequired" value="__StandardsExpiredRequired__"/>
<Setting name="AllowedCorsUrls" value="__AllowedCorsUrls__"/>
<Setting name="APPINSIGHTS_INSTRUMENTATIONKEY" value="__InstrumentationKey__"/>
</ConfigurationSettings>
<Certificates>
<Certificate name="WebSslCert" thumbprint="D4B7EBCE1013CBB10A6DD74D1A20E2C9A69107A2" thumbprintAlgorithm="sha1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<Setting name="AssessmentOrgsIndexAlias" value="__AssessmentOrgsIndexAlias__" />
<Setting name="FrameworksExpiredRequired" value="__FrameworksExpiredRequired__"/>
<Setting name="StandardsExpiredRequired" value="__StandardsExpiredRequired__"/>
<Setting name="AllowedCorsUrls" value="__AllowedCorsUrls__"/>
<Setting name="APPINSIGHTS_INSTRUMENTATIONKEY" value="__InstrumentationKey__"/>
</ConfigurationSettings>
<Certificates>
<Certificate name="WebSslCert" thumbprint="5FF7EED8A02C7C758CFDA2458752E7EACDDFEE8B" thumbprintAlgorithm="sha1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
<Setting name="AssessmentOrgsIndexAlias" value="__AssessmentOrgsIndexAlias__" />
<Setting name="FrameworksExpiredRequired" value="__FrameworksExpiredRequired__"/>
<Setting name="StandardsExpiredRequired" value="__StandardsExpiredRequired__"/>
<Setting name="AllowedCorsUrls" value="__AllowedCorsUrls__"/>
<Setting name="APPINSIGHTS_INSTRUMENTATIONKEY" value="__InstrumentationKey__"/>
</ConfigurationSettings>
<Certificates>
<Certificate name="WebSslCert" thumbprint="7A1BC8263B7CBAA2B355934D0BB8031B469C1AE1" thumbprintAlgorithm="sha1" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
<Setting name="AssessmentOrgsIndexAlias" />
<Setting name="FrameworksExpiredRequired" />
<Setting name="StandardsExpiredRequired"/>
<Setting name="AllowedCorsUrls" />
<Setting name="APPINSIGHTS_INSTRUMENTATIONKEY"/>
</ConfigurationSettings>
<Endpoints>
<InputEndpoint name="Endpoint1" protocol="http" port="80" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using System.Linq;
using System.Web.Http.Description;
using Swashbuckle.Swagger;

namespace Sfa.Das.ApprenticeshipInfoService.Api.Swagger
{

internal class RemoveV1ApiVersionParameter : IOperationFilter
{
public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
{
if (apiDescription.GetGroupName() == "v1" && operation.parameters != null)
{
var versionParameter = operation.parameters.SingleOrDefault(x => x.name == "api-version");

if (versionParameter != null)
{
operation.parameters.Remove(versionParameter);
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
using System.Linq;
using System.Web.Http.Description;
using Swashbuckle.Swagger;

namespace Sfa.Das.ApprenticeshipInfoService.Api.Swagger
{
internal class RemoveV1SpecificOperations : IDocumentFilter
{
public void Apply(SwaggerDocument swaggerDoc, SchemaRegistry schemaRegistry, IApiExplorer apiExplorer)
{
var v1Paths = swaggerDoc.paths.Where(x => x.Key.StartsWith("/v1/")).ToList();

foreach (var path in v1Paths)
{
swaggerDoc.paths.Remove(path.Key);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System.Linq;
using System.Web.Http.Description;
using Swashbuckle.Swagger;

namespace Sfa.Das.ApprenticeshipInfoService.Api.Swagger
{
/// <summary>
/// Represents the Swagger/Swashbuckle operation filter used to provide default values.
/// </summary>
/// <remarks>This <see cref="IOperationFilter"/> is only required due to bugs in the <see cref="SwaggerGenerator"/>.
/// Once they are fixed and published, this class can be removed.</remarks>
public class SwaggerDefaultValues : IOperationFilter
{
/// <summary>
/// Applies the filter to the specified operation using the given context.
/// </summary>
/// <param name="operation">The operation to apply the filter to.</param>
/// <param name="schemaRegistry">The API schema registry.</param>
/// <param name="apiDescription">The API description being filtered.</param>
public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
{
operation.deprecated = apiDescription.IsDeprecated();

if (operation.parameters == null)
{
return;
}

foreach (var parameter in operation.parameters)
{
var description = apiDescription.ParameterDescriptions.First(p => p.Name == parameter.name);

// REF: https://github.com/domaindrivendev/Swashbuckle/issues/1101
if (parameter.description == null)
{
parameter.description = description.Documentation;
}

// REF: https://github.com/domaindrivendev/Swashbuckle/issues/1089
// REF: https://github.com/domaindrivendev/Swashbuckle/pull/1090
if (parameter.@default == null)
{
parameter.@default = description.ParameterDescriptor?.DefaultValue;
}
}
}
}
}

0 comments on commit 775c164

Please sign in to comment.