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

Mapped total number of records to response #60

Merged
merged 1 commit into from
Nov 7, 2024
Merged
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 @@ -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