Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use infinite query for streaming endpoint #3885

Merged
merged 1 commit into from
Jan 2, 2025

Conversation

wesbillman
Copy link
Collaborator

This integrates tanstack infinite query to avoid reloading the entire timeline when new events arrive.

@wesbillman wesbillman requested a review from Copilot January 2, 2025 17:42
This was referenced Jan 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (1)

frontend/console/src/api/timeline/use-timeline.ts:51

  • Ensure that the sorting and filtering logic for 'queryClient.setQueryData' is covered by tests to verify that it is correct.
queryClient.setQueryData<InfiniteData<Event[]>>(queryKey, (old = { pages: [], pageParams: [] }) => { const newEvents = response.events const existingEvents = old.pages[0] || [] const uniqueNewEvents = newEvents.filter((newEvent) => !existingEvents.some((existingEvent) => existingEvent.id === newEvent.id)) const allEvents = [...uniqueNewEvents, ...existingEvents].sort((a, b) => { const aTime = a.timestamp const bTime = b.timestamp if (!aTime || !bTime) return 0 return Number(bTime.seconds - aTime.seconds) || Number(bTime.nanos - aTime.nanos) }).slice(0, maxTimelineEntries) return { pages: [allEvents, ...old.pages.slice(1)], pageParams: old.pageParams } })
@wesbillman wesbillman merged commit 17e177c into main Jan 2, 2025
65 checks passed
@wesbillman wesbillman deleted the use-tanstack-infinite-query branch January 2, 2025 18:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant