Skip to content

Commit

Permalink
add more comments, change query params type
Browse files Browse the repository at this point in the history
  • Loading branch information
nnamdifrankie committed Jan 3, 2020
1 parent cad4f76 commit 42e4f07
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
10 changes: 5 additions & 5 deletions x-pack/plugins/endpoint/server/routes/endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ export function registerEndpointRoutes(router: IRouter, endpointAppContext: Endp
}

function mapToEndpointResultList(
queryParams: Record<string, unknown>,
queryParams: Record<string, any>,
searchResponse: SearchResponse<EndpointData>
): EndpointResultList {
if (searchResponse.hits.hits.length > 0) {
return {
requestPageSize: queryParams.size as number,
requestIndex: queryParams.from as number,
requestPageSize: queryParams.size,
requestIndex: queryParams.from,
endpoints: searchResponse.hits.hits
.map(response => response.inner_hits.most_recent.hits.hits)
.flatMap(data => data as HitSource)
Expand All @@ -73,8 +73,8 @@ function mapToEndpointResultList(
};
} else {
return {
requestPageSize: queryParams.size as number,
requestIndex: queryParams.from as number,
requestPageSize: queryParams.size,
requestIndex: queryParams.from,
total: 0,
endpoints: [],
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ export class AllEndpointsQueryBuilder {
this.request = request;
this.endpointAppContext = endpointAppContext;
}

async toQueryParams(): Promise<Record<string, unknown>> {
/* aggregating by endpoint machine id and retrieving the latest of each group of events
related to an endpoint by machine id using elastic search collapse functionality
*/
async toQueryParams(): Promise<Record<string, any>> {
const paging = await this.paging();
return {
body: {
Expand Down

0 comments on commit 42e4f07

Please sign in to comment.