Skip to content

Commit

Permalink
Mapped total number of records to response (#60)
Browse files Browse the repository at this point in the history
Co-authored-by: Spencer O'HEGARTY <Spencer.OHEGARTY@EDUCATION.GOV.UK>
  • Loading branch information
spanersoraferty and spencerohegartyDfE authored Nov 7, 2024
1 parent 89ac543 commit cc675f4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,35 +26,17 @@ public sealed class SearchByKeywordResponse
public SearchResponseStatus Status { get; }

/// <summary>
/// Establishes the status of the underlying search response, i.e. Success or otherwise.
/// The Total Count returned from Establishment search gives us a total
/// of all available records which correlates with the given search criteria.
/// </summary>
/// <param name="status"></param>
public SearchByKeywordResponse(SearchResponseStatus status)
{
Status = status;
}
public int TotalNumberOfEstablishments { get; init; }

/// <summary>
/// The following argument is passed via the constructor and is not changeable
/// once an instance is created, this ensures we preserve immutability.
/// Establishes the status of the underlying search response, i.e. Success or otherwise.
/// </summary>
/// <param name="establishments">
/// The readonly collection of <see cref="EstablishmentResults"/>.
/// </param>
/// <param name="facetResults">
/// The readonly collection of <see cref="EstablishmentFacets"/>.
/// </param>
/// <param name="status">
/// The <see cref="SearchResponseStatus"/> of the result of the search.
/// </param>
public SearchByKeywordResponse(
EstablishmentResults establishments,
EstablishmentFacets facetResults,
SearchResponseStatus status
)
/// <param name="status"></param>
public SearchByKeywordResponse(SearchResponseStatus status)
{
EstablishmentResults = establishments;
EstablishmentFacetResults = facetResults;
Status = status;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ await _searchServiceAdapter.SearchAsync(
_ => new(status: SearchResponseStatus.Success)
{
EstablishmentResults = results.Establishments,
EstablishmentFacetResults = results.Facets
EstablishmentFacetResults = results.Facets,
TotalNumberOfEstablishments =
results.TotalNumberOfEstablishments.HasValue ?
(int)results.TotalNumberOfEstablishments : 0, // if not values default to zero.
}
};
}
Expand Down

0 comments on commit cc675f4

Please sign in to comment.