Skip to content

Conversation

@ktx-vaidehi
Copy link
Collaborator

@ktx-vaidehi ktx-vaidehi commented Jul 9, 2024

  • 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".

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.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 9, 2024

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 @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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.

Commits

Files that changed from the base of the PR and between 712e129 and b88b072.

Walkthrough

The recent changes primarily enhance the formatting of duration times and introduce pagination for query lists in the web application. The QueryList.vue component now provides more granular and consistent duration displays using the newly added queryManagementFormatDuration utility function. Additionally, the RunningQueriesList.vue component incorporates pagination to manage large sets of data more effectively.

Changes

Files Change Summary
web/src/components/queries/QueryList.vue Refactored duration logic to leverage queryManagementFormatDuration for detailed and consistent duration formatting.
web/src/components/queries/RunningQueriesList.vue Added pagination to the query table and adjusted duration formatting to match the updated logic using queryManagementFormatDuration.
web/src/utils/zincutils.ts Introduced queryManagementFormatDuration function to format duration into human-readable strings across various time units.

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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions github-actions bot added the ☢️ Bug Something isn't working label Jul 9, 2024
@ktx-vaidehi ktx-vaidehi marked this pull request as ready for review July 10, 2024 05:59
@ktx-vaidehi ktx-vaidehi force-pushed the fix/query-cancellation-time-range-and-pagination branch from ea34330 to 2eb1edf Compare July 10, 2024 06:00
Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between a5960b8 and 2eb1edf.

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 QTable component 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.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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

Commits

Files that changed from the base of the PR and between 2eb1edf and 712e129.

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

Comment on lines +741 to +752
/**
* 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.
*/
Copy link
Contributor

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;
};

Comment on lines 741 to 796
/**
* 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;
};
Copy link
Contributor

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?

@ktx-vaidehi ktx-vaidehi force-pushed the fix/query-cancellation-time-range-and-pagination branch from d13a155 to b88b072 Compare July 10, 2024 07:29
@ktx-vaidehi ktx-vaidehi merged commit be068a7 into main Jul 10, 2024
@ktx-vaidehi ktx-vaidehi deleted the fix/query-cancellation-time-range-and-pagination branch July 10, 2024 08:37
taimingl pushed a commit that referenced this pull request Jul 12, 2024
- 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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

☢️ Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants