Skip to content

Commit fe16d22

Browse files
afgomezAlejandro Fernández Gómez
authored andcommitted
Fix before pagination
1 parent 0319c80 commit fe16d22

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

x-pack/plugins/infra/server/lib/adapters/log_entries/kibana_log_entries_adapter.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,17 @@ export class InfraKibanaLogEntriesAdapter implements LogEntriesAdapter {
113113
esQuery
114114
);
115115

116-
const hits = sortDirection === 'asc' ? esResult.hits.hits : esResult.hits.hits.reverse();
116+
const hits = esResult.hits.hits;
117117
const hasMore = hits.length > size;
118118

119119
if (hasMore) {
120120
hits.pop();
121121
}
122122

123+
if (sortDirection === 'desc') {
124+
hits.reverse();
125+
}
126+
123127
return {
124128
documents: mapHitsToLogEntryDocuments(hits, fields),
125129
hasMoreBefore: sortDirection === 'desc' ? hasMore : undefined,

0 commit comments

Comments
 (0)