Skip to content

Commit

Permalink
api: add facets parameter to getRecords
Browse files Browse the repository at this point in the history
Adds the `facets` paramter to `getRecords` method. This parameter allow
to define which aggregation values should be included into API response.
By default, no aggregation should be include.

Co-authored-by: Renaud Michotte <renaud.michotte@gmail.com>
Co-authored-by: Sébastien Delèze <sebastien.deleze@rero.ch>
  • Loading branch information
zannkukai and Sébastien Delèze committed Jul 19, 2021
1 parent 66c5c0c commit 89d54f7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion projects/rero/ng-core/src/lib/record/record.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ export class RecordService {
* a string or a list of string to filter with multiple values.
* @param headers - HttpHeaders optional http header for the backend call.
* @param sort - parameter for sorting records (eg. 'mostrecent' or '-mostrecent')
* @param facets - list of strings, define which aggregations/facets should be included into the response.
*/
getRecords(
type: string,
Expand All @@ -110,7 +111,8 @@ export class RecordService {
aggregationsFilters: any[] = [],
preFilters: object = {},
headers: any = null,
sort: string = null
sort: string = null,
facets: string[] = []
): Observable<Record | Error> {
// Build query string
let httpParams = new HttpParams().set('q', query);
Expand Down Expand Up @@ -140,6 +142,10 @@ export class RecordService {
}
}

// facets management
// if array `facets` is an empty array, no aggregations data will be included into response.s
httpParams = httpParams.append('facets', facets.join(','));

// http request with headers
return this._http
.get<Record>(this._apiService.getEndpointByType(type, true) + '/', {
Expand Down

0 comments on commit 89d54f7

Please sign in to comment.