Skip to content

Commit

Permalink
Tweak cursor handling in the routes
Browse files Browse the repository at this point in the history
  • Loading branch information
Alejandro Fernández Gómez committed Jan 2, 2020
1 parent c454479 commit c5e231a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
15 changes: 8 additions & 7 deletions x-pack/legacy/plugins/infra/server/routes/log_entries/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
logEntriesResponseRT,
} from '../../../common/http_api/log_entries';
import { parseFilterQuery } from '../../utils/serialized_query';
import { LogEntriesParams } from '../../lib/domains/log_entries_domain';

const escapeHatch = schema.object({}, { allowUnknowns: true });

Expand All @@ -39,13 +40,6 @@ export const initLogEntriesRoute = ({ framework, logEntries }: InfraBackendLibs)

const { startDate, endDate, sourceId, query, size } = payload;

let cursor;
if ('before' in payload) {
cursor = { before: payload.before };
} else if ('after' in payload) {
cursor = { after: payload.after };
}

let entries;
if ('center' in payload) {
entries = await logEntries.getLogEntriesAround__new(requestContext, sourceId, {
Expand All @@ -56,6 +50,13 @@ export const initLogEntriesRoute = ({ framework, logEntries }: InfraBackendLibs)
size,
});
} else {
let cursor: LogEntriesParams['cursor'];
if ('before' in payload) {
cursor = { before: payload.before };
} else if ('after' in payload) {
cursor = { after: payload.after };
}

entries = await logEntries.getLogEntries(requestContext, sourceId, {
startDate,
endDate,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
logEntriesHighlightsResponseRT,
} from '../../../common/http_api/log_entries';
import { parseFilterQuery } from '../../utils/serialized_query';
import { LogEntriesParams } from '../../lib/domains/log_entries_domain';

const escapeHatch = schema.object({}, { allowUnknowns: true });

Expand Down Expand Up @@ -55,7 +56,7 @@ export const initLogEntriesHighlightsRoute = ({ framework, logEntries }: InfraBa
)
);
} else {
let cursor;
let cursor: LogEntriesParams['cursor'];
if ('before' in payload) {
cursor = { before: payload.before };
} else if ('after' in payload) {
Expand Down

0 comments on commit c5e231a

Please sign in to comment.