From c41f60dbfbc879eea451f3d9c8f217d2aba4ecf2 Mon Sep 17 00:00:00 2001 From: Spencer O'HEGARTY Date: Thu, 7 Nov 2024 10:21:33 +0000 Subject: [PATCH] Mapped total number of records to response --- .../Usecase/SearchByKeywordResponse.cs | 30 ++++--------------- .../Usecase/SearchByKeywordUseCase.cs | 5 +++- 2 files changed, 10 insertions(+), 25 deletions(-) diff --git a/Dfe.Data.SearchPrototype/SearchForEstablishments/ByKeyword/Usecase/SearchByKeywordResponse.cs b/Dfe.Data.SearchPrototype/SearchForEstablishments/ByKeyword/Usecase/SearchByKeywordResponse.cs index a595788..37484bf 100644 --- a/Dfe.Data.SearchPrototype/SearchForEstablishments/ByKeyword/Usecase/SearchByKeywordResponse.cs +++ b/Dfe.Data.SearchPrototype/SearchForEstablishments/ByKeyword/Usecase/SearchByKeywordResponse.cs @@ -26,35 +26,17 @@ public sealed class SearchByKeywordResponse public SearchResponseStatus Status { get; } /// - /// 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. /// - /// - public SearchByKeywordResponse(SearchResponseStatus status) - { - Status = status; - } + public int TotalNumberOfEstablishments { get; init; } /// - /// 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. /// - /// - /// The readonly collection of . - /// - /// - /// The readonly collection of . - /// - /// - /// The of the result of the search. - /// - public SearchByKeywordResponse( - EstablishmentResults establishments, - EstablishmentFacets facetResults, - SearchResponseStatus status - ) + /// + public SearchByKeywordResponse(SearchResponseStatus status) { - EstablishmentResults = establishments; - EstablishmentFacetResults = facetResults; Status = status; } } diff --git a/Dfe.Data.SearchPrototype/SearchForEstablishments/ByKeyword/Usecase/SearchByKeywordUseCase.cs b/Dfe.Data.SearchPrototype/SearchForEstablishments/ByKeyword/Usecase/SearchByKeywordUseCase.cs index f48540a..aeb79ac 100644 --- a/Dfe.Data.SearchPrototype/SearchForEstablishments/ByKeyword/Usecase/SearchByKeywordUseCase.cs +++ b/Dfe.Data.SearchPrototype/SearchForEstablishments/ByKeyword/Usecase/SearchByKeywordUseCase.cs @@ -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. } }; }