Skip to content

Commit

Permalink
Merge pull request #40 from DFE-Digital/CL/facet-response-for-UI
Browse files Browse the repository at this point in the history
Cl/facet response for UI
  • Loading branch information
RogerHowellDfE authored Aug 29, 2024
2 parents 081523a + 5c0e1c9 commit 8bbb74d
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
namespace Dfe.Data.SearchPrototype.SearchForEstablishments.Models;

/// <summary>
/// The object that encapsulates the Faceted results returned by the
/// T:Dfe.Data.SearchPrototype.SearchForEstablishments.SearchByKeywordUseCase instance
/// </summary>
public class EstablishmentFacet
{
/// <summary>
/// The facet (field) name
/// </summary>
public string Name { get; }

/// <summary>
/// The collection of T:Dfe.Data.SearchPrototype.SearchForEstablishments.Models.FacetResult
/// </summary>
public IList<FacetResult> Results { get; }

/// <summary>
/// Constructor
/// </summary>
/// <param name="facetName"></param>
/// <param name="facetResults"></param>
public EstablishmentFacet(string facetName, IList<FacetResult> facetResults)
{
Name = facetName;
Results = facetResults;
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
namespace Dfe.Data.SearchPrototype.SearchForEstablishments.Models;

/// <summary>
/// The object that encapsulates a single facet result for a facet
/// </summary>
public class FacetResult
{
/// <summary>
/// The value of the facet result
/// </summary>
public string Value { get; }

/// <summary>
/// The number of records that belong to this facet value
/// </summary>
public int? Count { get; }

/// <summary>
/// Constructor
/// </summary>
/// <param name="value">The value of the facet result</param>
/// <param name="count">The number of records that belong to this facet value</param>
public FacetResult(string value, int? count)
{
Value = value;
Count = count;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,29 @@

namespace Dfe.Data.SearchPrototype.SearchForEstablishments;




/// <summary>
/// This is the object that carries the response (output) back from the
/// T:Dfe.Data.SearchPrototype.SearchForEstablishments.SearchByKeywordUseCase instance.
/// The response will encapsulate any search results found along with a status.
/// </summary>
public sealed class SearchByKeywordResponse
{
/// <summary>
/// The readonly collection of T:Dfe.Data.SearchPrototype.Search.Establishment search results.
/// </summary>
public IReadOnlyCollection<Establishment> EstablishmentResults { get;}

/// <summary>
/// The readonly collection of T:Dfe.Data.SearchPrototype.Search.EstablishmentFacet returned by the Establishment search
/// </summary>
public IReadOnlyCollection<EstablishmentFacet>? EstablishmentFacetResults { get; }

/// <summary>
/// The return status of the call to the
/// T:Dfe.Data.SearchPrototype.SearchForEstablishments.SearchByKeywordUseCase instance
/// </summary>
public SearchResponseStatus Status { get; set; }

/// <summary>
Expand All @@ -30,8 +42,12 @@ public SearchByKeywordResponse()
/// <param name="establishments">
/// The readonly collection of T:Dfe.Data.SearchPrototype.Search.Establishment search results.
/// </param>
public SearchByKeywordResponse(IReadOnlyCollection<Establishment> establishments)
/// <param name="facetResults">
/// The readonly collection of T:Dfe.Data.SearchPrototype.Search.EstablishmentFacet
/// </param>
public SearchByKeywordResponse(IReadOnlyCollection<Establishment> establishments, IReadOnlyCollection<EstablishmentFacet>? facetResults = null)
{
EstablishmentResults = establishments;
EstablishmentFacetResults = facetResults;
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,20 @@
namespace Dfe.Data.SearchPrototype.SearchForEstablishments;

/// <summary>
/// The status of the search response
/// </summary>
public enum SearchResponseStatus
{
/// <summary>
/// The search request completed successfully
/// </summary>
Success,
/// <summary>
/// The request was not valid
/// </summary>
InvalidRequest,
/// <summary>
/// The request was submitted and resulted in an error
/// </summary>
SearchServiceError
}

0 comments on commit 8bbb74d

Please sign in to comment.