dice icon indicating copy to clipboard operation
dice copied to clipboard

Migrated ZRANK Command

Open prabhavdogra opened this issue 9 months ago • 1 comments

Summary by CodeRabbit

  • New Features
    • Added a new command that retrieves the rank of a member in a sorted collection. When the optional flag is enabled, the corresponding score is also returned.
    • Enhanced response formatting for lists of integer values, ensuring clearer and more consistent outputs.
    • These enhancements ensure a refined user experience with reliable command execution.

prabhavdogra avatar Mar 31 '25 16:03 prabhavdogra

Walkthrough

The pull request introduces a new "ZRANK" command in the cmd package, which retrieves the rank (and optionally the score) of a member in a sorted set. It includes functions for argument parsing, evaluation, and execution, along with error handling for cases such as invalid arguments, missing keys, or absent members. Additionally, a new helper function is added in cmds.go to convert an integer slice into a command result using Google Protobuf.

Changes

File Path Change Summary
internal/cmd/cmd_zrank.go - Added new ZRANK command with metadata, parsing (parseZRANKArgs), evaluation (evalZRANK), and execution (executeZRANK) functions.
- Implements error handling for key/member validation.
- Command registered during initialization.
internal/cmd/cmds.go - Introduced new function cmdResIntSlice to convert a slice of int64 values into a CmdRes with a Protobuf value list.
- Added import for structpb from google.golang.org/protobuf/types/known/structpb.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant CP as Command Processor
    participant ZRFunc as ZRANK Functions
    participant Store as Data Store

    Client->>CP: Submit "ZRANK" command with arguments
    CP->>CP: Invoke parseZRANKArgs to validate input
    CP->>Store: Check for existence of key and member
    Store-->>CP: Return validation/lookup results
    CP->>ZRFunc: Call evalZRANK for rank (and score) evaluation
    ZRFunc-->>CP: Return rank (and optional score) or error
    CP->>Client: Respond with command result

Poem

I'm a rabbit hopping through the byte-filled lane,
New commands spring forth like a joyful refrain.
ZRANK brings ranks with a gentle pace,
Integer slices join the digital race.
In lines of code, I celebrate this nifty gain!
🐰💻 Happy hops in the realm of code!

✨ Finishing Touches
  • [ ] 📝 Generate Docstrings

🪧 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

coderabbitai[bot] avatar Mar 31 '25 16:03 coderabbitai[bot]