-
Notifications
You must be signed in to change notification settings - Fork 715
fix: sorting issue in query management page #8305
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Greptile Summary
This PR addresses sorting issues in the query management page by implementing proper data formatting for duration and query range columns. The changes introduce two new utility functions in zincutils.ts: localTimeToMicroseconds() to get current time in microseconds, and getDuration(createdAt) to calculate duration differences with formatted output.
The fix modifies three Vue components that display query data. In RunningQueriesList.vue and SummaryList.vue, custom cell templates are added that use the new utility functions to format duration and query range values for display. The core data structure changes are in RunningQueries.vue, where the duration and query range fields now store raw numeric values instead of pre-formatted strings.
This approach separates data storage from presentation - tables now store sortable numeric values (timestamps, seconds) while the display components format these values into human-readable strings using durationFormatter() and getDuration(). This ensures JavaScript's numeric sorting works correctly for large datasets while maintaining user-friendly display formatting.
Confidence score: 2/5
- This PR has significant implementation inconsistencies that could cause runtime issues
- Score lowered due to incorrect duration field assignment and potential data flow problems between components
- Pay close attention to RunningQueries.vue data assignment logic and verify the removed getDuration function doesn't break existing functionality
4 files reviewed, 4 comments
|
|
||
| export const localTimeToMicroseconds = () => { | ||
| // Create a Date object representing the current local time | ||
| var date = new Date(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Use const instead of var for better scoping
| var date = new Date(); | |
| const date = new Date(); |
| var date = new Date(); | ||
|
|
||
| // Get the timestamp in milliseconds | ||
| var timestampMilliseconds = date.getTime(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Use const instead of var for better scoping
| var timestampMilliseconds = date.getTime(); | |
| const timestampMilliseconds = date.getTime(); |
| var timestampMilliseconds = date.getTime(); | ||
|
|
||
| // Convert milliseconds to microseconds | ||
| var timestampMicroseconds = timestampMilliseconds * 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: Use const instead of var for better scoping
| var timestampMicroseconds = timestampMilliseconds * 1000; | |
| const timestampMicroseconds = timestampMilliseconds * 1000; |
| duration: getDuration(row?.created_at).duration, | ||
| queryRange: queryRange(row?.query?.start_time, row?.query?.end_time) | ||
| .duration, | ||
| duration: row.created_at, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: Storing row.created_at as duration seems incorrect - this is a timestamp, not a calculated duration. Should this be getDuration(row.created_at).durationInSeconds?
| duration: row.created_at, | |
| duration: getDuration(row.created_at).durationInSeconds, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the correct suggestion , I have changed that
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
dc1197a to
d0a69a9
Compare
d0a69a9 to
5a4afbd
Compare
User description
This PR fixes the issue that is related to sorting doesn't work properly for more number of records for execution duration and query range
PR Type
Bug fix, Enhancement
Description
Centralize duration utilities in
zincutilsFix sorting by using raw seconds
Render durations via table slots
Improve query range formatting
Diagram Walkthrough
File Walkthrough
zincutils.ts
Add shared time/duration utilitiesweb/src/utils/zincutils.ts
localTimeToMicrosecondshelper.getDurationreturning seconds and formatted.RunningQueriesList.vue
Render durations via slots using utilsweb/src/components/queries/RunningQueriesList.vue
durationandqueryRange.getDurationanddurationFormatter.created_atvia util.SummaryList.vue
Format summary durations with table slotsweb/src/components/queries/SummaryList.vue
durationandqueryRange.durationFormatter.RunningQueries.vue
Use raw values and shared duration utilweb/src/components/queries/RunningQueries.vue
getDurationfrom utils.durationandqueryRangeas raw values.getDurationimpl.