-
Notifications
You must be signed in to change notification settings - Fork 715
fix: query management exec dur, query range and pagination fix #3934
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
fix: query management exec dur, query range and pagination fix #3934
Conversation
|
Warning Rate limit exceeded@ktx-vaidehi has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 19 minutes and 5 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe recent changes primarily enhance the formatting of duration times and introduce pagination for query lists in the web application. The Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
ea34330 to
2eb1edf
Compare
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.
Actionable comments posted: 0
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (2)
- web/src/components/queries/QueryList.vue (4 hunks)
- web/src/components/queries/RunningQueriesList.vue (6 hunks)
Additional comments not posted (4)
web/src/components/queries/QueryList.vue (1)
134-162: LGTM! Granular duration formatting is well-implemented.The function is well-structured and effectively handles different duration ranges.
web/src/components/queries/RunningQueriesList.vue (3)
8-8: LGTM! Pagination integration is well-implemented.The pagination addition to the
QTablecomponent appears to be correctly integrated.
299-319: LGTM! Granular duration formatting is well-implemented.The function is well-structured and effectively handles different duration ranges.
328-356: LGTM! Granular duration formatting is well-implemented.The function is well-structured and effectively handles different duration ranges.
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.
Actionable comments posted: 2
Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Files selected for processing (3)
- web/src/components/queries/QueryList.vue (3 hunks)
- web/src/components/queries/RunningQueriesList.vue (5 hunks)
- web/src/utils/zincutils.ts (1 hunks)
Files skipped from review as they are similar to previous changes (2)
- web/src/components/queries/QueryList.vue
- web/src/components/queries/RunningQueriesList.vue
| /** | ||
| * Formats the duration in seconds into a human-readable string representation. | ||
| * The format of the output string is: | ||
| * - For durations less than 60 seconds, returns the duration in seconds. | ||
| * - For durations less than 3600 seconds (1 hour), returns minutes and seconds. | ||
| * - For durations less than 86400 seconds (1 day), returns hours, minutes, and seconds. | ||
| * - For durations equal to or greater than 1 day, returns days, hours, minutes, and seconds. | ||
| * - If no value(0) than removes the duration from the string. | ||
| * | ||
| * @param {number} durationInSeconds - The duration in seconds to be formatted. | ||
| * @return {string} The formatted duration string. | ||
| */ |
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.
Consider using a switch-case statement for better readability.
The current implementation uses multiple if-else blocks. A switch-case statement could improve readability and maintainability.
export const queryManagementFormatDuration = (
durationInSeconds: number
): string => {
let formattedDuration;
switch (true) {
case durationInSeconds < 0:
formattedDuration = "Invalid duration";
break;
case durationInSeconds < 60:
formattedDuration = `${durationInSeconds}s`;
break;
case durationInSeconds < 3600:
const minutes = Math.floor(durationInSeconds / 60);
const seconds = durationInSeconds % 60;
formattedDuration = `${minutes > 0 ? `${minutes}m ` : ""}${
seconds > 0 ? `${seconds}s` : ""
}`.trim();
break;
case durationInSeconds < 86400:
const hours = Math.floor(durationInSeconds / 3600);
const minutes = Math.floor((durationInSeconds % 3600) / 60);
const seconds = durationInSeconds % 60;
formattedDuration = `${hours > 0 ? `${hours}h ` : ""}${
minutes > 0 ? `${minutes}m ` : ""
}${seconds > 0 ? `${seconds}s` : ""}`.trim();
break;
default:
const days = Math.floor(durationInSeconds / 86400);
const hours = Math.floor((durationInSeconds % 86400) / 3600);
const minutes = Math.floor((durationInSeconds % 3600) / 60);
const seconds = durationInSeconds % 60;
formattedDuration = `${days > 0 ? `${days}d ` : ""}${
hours > 0 ? `${hours}h ` : ""
}${minutes > 0 ? `${minutes}m ` : ""}${
seconds > 0 ? `${seconds}s` : ""
}`.trim();
break;
}
return formattedDuration;
};| /** | ||
| * Formats the duration in seconds into a human-readable string representation. | ||
| * The format of the output string is: | ||
| * - For durations less than 60 seconds, returns the duration in seconds. | ||
| * - For durations less than 3600 seconds (1 hour), returns minutes and seconds. | ||
| * - For durations less than 86400 seconds (1 day), returns hours, minutes, and seconds. | ||
| * - For durations equal to or greater than 1 day, returns days, hours, minutes, and seconds. | ||
| * - If no value(0) than removes the duration from the string. | ||
| * | ||
| * @param {number} durationInSeconds - The duration in seconds to be formatted. | ||
| * @return {string} The formatted duration string. | ||
| */ | ||
| export const queryManagementFormatDuration = ( | ||
| durationInSeconds: number | ||
| ): string => { | ||
| let formattedDuration; | ||
|
|
||
| // If duration is invalid, set formatted duration to "Invalid duration" | ||
| // For example, if the duration is -1 seconds, the output string will be "Invalid duration". | ||
| if (durationInSeconds < 0) { | ||
| formattedDuration = "Invalid duration"; | ||
| } else if (durationInSeconds < 60) { | ||
| // If duration is less than 60 seconds, return duration in seconds | ||
| // For example, if the duration is 30 seconds, the output string will be "30s". | ||
| formattedDuration = `${durationInSeconds}s`; | ||
| } else if (durationInSeconds < 3600) { | ||
| // If duration is less than 1 hour, calculate minutes and seconds and return | ||
| // For example, if the duration is 150 seconds, the output string will be "2m 30s". | ||
| const minutes = Math.floor(durationInSeconds / 60); | ||
| const seconds = durationInSeconds % 60; | ||
| formattedDuration = `${minutes > 0 ? `${minutes}m ` : ""}${ | ||
| seconds > 0 ? `${seconds}s` : "" | ||
| }`.trim(); | ||
| } else if (durationInSeconds < 86400) { | ||
| // If duration is less than 1 day, calculate hours, minutes, and seconds and return | ||
| // For example, if the duration is 7200 seconds, the output string will be "2h". | ||
| const hours = Math.floor(durationInSeconds / 3600); | ||
| const minutes = Math.floor((durationInSeconds % 3600) / 60); | ||
| const seconds = durationInSeconds % 60; | ||
| formattedDuration = `${hours > 0 ? `${hours}h ` : ""}${ | ||
| minutes > 0 ? `${minutes}m ` : "" | ||
| }${seconds > 0 ? `${seconds}s` : ""}`.trim(); | ||
| } else { | ||
| // If duration is equal to or greater than 1 day, calculate days, hours, minutes, and seconds and return | ||
| // For example, if the durartion is 86900 seconds, the output string will be "1d 8m 20s". | ||
| const days = Math.floor(durationInSeconds / 86400); | ||
| const hours = Math.floor((durationInSeconds % 86400) / 3600); | ||
| const minutes = Math.floor((durationInSeconds % 3600) / 60); | ||
| const seconds = durationInSeconds % 60; | ||
| formattedDuration = `${days > 0 ? `${days}d ` : ""}${ | ||
| hours > 0 ? `${hours}h ` : "" | ||
| }${minutes > 0 ? `${minutes}m ` : ""}${ | ||
| seconds > 0 ? `${seconds}s` : "" | ||
| }`.trim(); | ||
| } | ||
|
|
||
| return formattedDuration; | ||
| }; |
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.
Add unit tests for queryManagementFormatDuration.
Ensure the function is covered by unit tests to verify its correctness across different scenarios.
Would you like me to generate the unit testing code or open a GitHub issue to track this task?
d13a155 to
b88b072
Compare
- For example, if the duration is 150 seconds, the output string will be "2m 30s". - For example, if the duration is 7200 seconds, the output string will be "2h". - For example, if the durartion is 86900 seconds, the output string will be "1d 8m 20s". <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **New Features** - Introduced pagination to the query table in the Running Queries List. - **Enhancements** - Improved duration formatting in the Query List and Running Queries List for more detailed and granular time representations. - **Consistency** - Ensured consistent duration formatting using the new `queryManagementFormatDuration` function. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary by CodeRabbit
New Features
Enhancements
Consistency
queryManagementFormatDurationfunction.