From fe7f938d393000f81090ae437918d29100df3b9b Mon Sep 17 00:00:00 2001 From: Wes Date: Tue, 19 Sep 2023 07:52:54 -0700 Subject: [PATCH] fix: request graph loading calls in reverse order (#409) Fixes #405 Screenshot 2023-09-19 at 7 31 28 AM --- console/client/src/components/CodeBlock.tsx | 2 +- .../client/src/features/timeline/Timeline.tsx | 2 +- .../client/src/services/console.service.ts | 28 +++++++++++-------- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/console/client/src/components/CodeBlock.tsx b/console/client/src/components/CodeBlock.tsx index 976f9e6793..9a18af2e8c 100644 --- a/console/client/src/components/CodeBlock.tsx +++ b/console/client/src/components/CodeBlock.tsx @@ -22,7 +22,7 @@ export const CodeBlock = ({ code, language, maxHeight }: Props) => { return (
-      {code}
+      {code}
     
) } diff --git a/console/client/src/features/timeline/Timeline.tsx b/console/client/src/features/timeline/Timeline.tsx index 3674c1d63f..4645b7e8cb 100644 --- a/console/client/src/features/timeline/Timeline.tsx +++ b/console/client/src/features/timeline/Timeline.tsx @@ -36,7 +36,7 @@ export const Timeline = ({ timeSettings, filters }: Props) => { if (timeSettings.newerThan || timeSettings.olderThan) { eventFilters = [timeFilter(timeSettings.olderThan, timeSettings.newerThan), ...filters] } - const events = await getEvents(eventFilters) + const events = await getEvents({ filters: eventFilters }) setEntries(events) } diff --git a/console/client/src/services/console.service.ts b/console/client/src/services/console.service.ts index 623680fa38..8a581b6a8a 100644 --- a/console/client/src/services/console.service.ts +++ b/console/client/src/services/console.service.ts @@ -93,7 +93,9 @@ export const timeFilter = (olderThan: Timestamp | undefined, newerThan: Timestam } export const getRequestCalls = async (requestKey: string): Promise => { - const allEvents = await getEvents([requestKeysFilter([requestKey]), eventTypesFilter([EventType.CALL])]) + const allEvents = await getEvents({ + filters: [requestKeysFilter([requestKey]), eventTypesFilter([EventType.CALL])], + }) return allEvents.map((e) => e.entry.value) as Call[] } @@ -102,20 +104,24 @@ export const getCalls = async ( destVerb: string | undefined = undefined, sourceModule: string | undefined = undefined, ): Promise => { - const allEvents = await getEvents([ - callFilter(destModule, destVerb, sourceModule), - eventTypesFilter([EventType.CALL]), - ]) + const allEvents = await getEvents({ + filters: [callFilter(destModule, destVerb, sourceModule), eventTypesFilter([EventType.CALL])], + }) return allEvents.map((e) => e.entry.value) as Call[] } -export const getEvents = async ( - filters: EventsQuery_Filter[] = [], - limit: number = 100, - order: EventsQuery_Order = EventsQuery_Order.DESC, -): Promise => { - const response = await client.getEvents({ filters, limit, order }) +interface GetEventsParams { + limit?: number + order?: EventsQuery_Order + filters?: EventsQuery_Filter[] +} +export const getEvents = async ({ + limit = 1000, + order = EventsQuery_Order.ASC, + filters = [], +}: GetEventsParams): Promise => { + const response = await client.getEvents({ filters, limit, order }) return response.events }