Skip to content

Commit

Permalink
Refactor processCursor
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 5829456 commit c454479
Showing 1 changed file with 15 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -497,23 +497,24 @@ function processCursor(
sortDirection: 'asc' | 'desc';
searchAfterClause: { search_after?: readonly [number, number] };
} {
let sortDirection: 'asc' | 'desc' = 'asc';
let searchAfterClause = {};

if (!cursor) {
return { sortDirection, searchAfterClause };
}

if ('before' in cursor) {
sortDirection = 'desc';
if (cursor.before !== 'last') {
searchAfterClause = { search_after: [cursor.before.time, cursor.before.tiebreaker] as const };
if (cursor) {
if ('before' in cursor) {
return {
sortDirection: 'desc',
searchAfterClause:
cursor.before !== 'last'
? { search_after: [cursor.before.time, cursor.before.tiebreaker] as const }
: {},
};
} else if (cursor.after !== 'first') {
return {
sortDirection: 'asc',
searchAfterClause: { search_after: [cursor.after.time, cursor.after.tiebreaker] as const },
};
}
} else if ('after' in cursor && cursor.after !== 'first') {
searchAfterClause = { search_after: [cursor.after.time, cursor.after.tiebreaker] as const };
}

return { sortDirection, searchAfterClause };
return { sortDirection: 'asc', searchAfterClause: {} };
}

const LogSummaryDateRangeBucketRuntimeType = runtimeTypes.intersection([
Expand Down

0 comments on commit c454479

Please sign in to comment.