Skip to content

Fixed Expectation to be both id & uuid - #155

Open
AFAskar wants to merge 2 commits into
devfrom
HotFix/BothClubId&UUID-Accepted
Open

Fixed Expectation to be both id & uuid#155
AFAskar wants to merge 2 commits into
devfrom
HotFix/BothClubId&UUID-Accepted

Conversation

@AFAskar

@AFAskar AFAskar commented Jun 2, 2025

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features
    • You can now retrieve club information and memberships using either a UUID or a numeric ID, making it easier to access club data with different types of identifiers.

@coderabbitai

coderabbitai Bot commented Jun 2, 2025

Copy link
Copy Markdown

Walkthrough

A new helper function for validating numeric IDs and an exported function to retrieve club data by either UUID or numeric ID were added. The getAllClubMemberships function was updated to accept both UUID and numeric ID, using the new retrieval logic. The controller was updated to call the new function. Module exports were updated accordingly.

Changes

File(s) Change Summary
services/clubService.js Added isNumericId helper, new findClubById function, updated getAllClubMemberships to accept UUID or numeric ID, updated exports.
controllers/clubController.js Modified getClubByUuid to call findClubById instead of findByUUID.
API-REST/Club/Club-get-info.bru Changed pre-request variable clubUuid from UUID string to numeric string (1).

Sequence Diagram(s)

sequenceDiagram
    participant Caller
    participant clubService

    Caller->>clubService: getAllClubMemberships(clubId, params)
    clubService->>clubService: findClubById(clubId, params)
    alt clubId is UUID
        clubService->>clubService: findByUUID(clubId)
    else clubId is numeric
        clubService->>DB: find club by numeric ID
    else invalid
        clubService->>Caller: throw 400 error
    end
    clubService->>DB: fetch memberships (with pagination/filtering/sorting)
    clubService-->>Caller: return memberships
Loading

Possibly related PRs

Suggested reviewers

  • Fkhrayef

Poem

A club can be found by number or string,
With helpers and checks, the results they bring.
Memberships fetched with logic anew,
Whether UUID or digits will do!
Hop, hop, hooray—let’s celebrate,
For flexible clubs are truly great!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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>, please review it.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in this 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.

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 coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
services/clubService.js (1)

305-328: Fix JSDoc parameter documentation.

The parameter name was correctly updated from clubUuid to clubId, but the JSDoc comment still references the old name.

Apply this diff to fix the documentation:

 /**
  * Get all memberships for a club
- * @param {String|Number} clubId Club ID or UUID
+ * @param {String|Number} clubId Club ID or UUID
  * @param {Object} params Query parameters

The implementation correctly uses the new findClubById function. Good work maintaining the existing pagination and filtering logic.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a6a2d9 and da464a3.

📒 Files selected for processing (1)
  • services/clubService.js (5 hunks)
🔇 Additional comments (2)
services/clubService.js (2)

16-19: LGTM! Clean validation helper function.

The isNumericId helper correctly validates positive integers with comprehensive checks for NaN, integer type, and positive value.


869-869: LGTM! Properly exported the new function.

The new findClubById function is correctly added to the module exports.

Comment thread services/clubService.js

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (3)
API-REST/Club/Club-get-info.bru (2)

34-34: Update documentation to reflect dual identifier support.

The documentation still states "UUID of the club to retrieve" but the API now accepts both UUIDs and numeric IDs. Consider updating to something like "UUID or numeric ID of the club to retrieve".

-  - `clubUuid`: UUID of the club to retrieve
+  - `clubUuid`: UUID or numeric ID of the club to retrieve

44-44: Update example to show both identifier types.

The example URL still uses a UUID. Consider adding an example showing numeric ID usage as well.

  ## Example

GET /clubs/550e8400-e29b-41d4-a716-446655440000?fields=name,description,status&include=supervisor

  • GET /clubs/1?fields=name,description,status&include=supervisor

</blockquote></details>
<details>
<summary>controllers/clubController.js (1)</summary><blockquote>

`24-24`: **Consider updating function name for clarity.**

The function name `getClubByUuid` is now misleading since it accepts both UUIDs and numeric IDs. Consider renaming to something like `getClubById` or `getClubByIdentifier` for better clarity.

Note: This may be a breaking change if the function is exported and used elsewhere, so evaluate the impact before making this change.

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between da464a3b603e7559dd4dcc67e76b77e30f54170f and 47116167e2ba670298d2bc3028566f772f53cc09.

</details>

<details>
<summary>📒 Files selected for processing (3)</summary>

* `API-REST/Club/Club-get-info.bru` (1 hunks)
* `controllers/clubController.js` (1 hunks)
* `services/clubService.js` (5 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (1)</summary>

* services/clubService.js

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🧬 Code Graph Analysis (1)</summary>

<details>
<summary>controllers/clubController.js (1)</summary><blockquote>

<details>
<summary>services/clubService.js (8)</summary>

* `clubData` (134-137)
* `clubData` (164-167)
* `clubData` (192-198)
* `clubData` (313-313)
* `clubData` (476-476)
* `clubData` (614-614)
* `clubData` (684-684)
* `clubData` (805-805)

</details>

</blockquote></details>

</details>

</details>

<details>
<summary>🔇 Additional comments (3)</summary><blockquote>

<details>
<summary>API-REST/Club/Club-get-info.bru (1)</summary>

`19-19`: **LGTM! Test parameter correctly validates numeric ID support.**

The change from UUID to numeric ID "1" properly tests the new dual identifier functionality.

</details>
<details>
<summary>controllers/clubController.js (2)</summary>

`25-28`: **LGTM! Correctly implements dual identifier support.**

The change from `findByUUID` to `findClubById` properly implements the new functionality to accept both UUIDs and numeric IDs.

---

`52-53`: <details>
<summary>❓ Verification inconclusive</summary>

**Verify consistency of identifier handling across controller functions.**

Several other functions in this controller still use `req.params.clubUuid` parameter. Ensure this is intentional if these functions should only accept UUIDs, or consider updating them to use the new dual identifier support if applicable.





Also applies to: 68-68, 79-80, 111-112, 148-149, 163-164, 188-189

---

🏁 Script executed:

```shell
#!/bin/bash
# Description: Check which service methods are called by other controller functions
# and verify if they support dual identifiers

echo "Checking service method calls in clubController.js:"
rg -A 2 -B 1 "clubService\." controllers/clubController.js

echo -e "\nChecking if other service methods support dual identifiers:"
rg -A 5 -B 2 "(updateClub|deleteClub|getAllClubMemberships|createMembership|joinClub|leaveClub|resetClubTerm)" services/clubService.js

Length of output: 4597


🏁 Script executed:

#!/bin/bash
# Extract implementation of findClubById to verify identifier handling
rg -n -A 20 "const findClubById" services/clubService.js

Length of output: 761


Identifier Support Consistency

The service layer currently only supports dual identifiers (UUID and numeric ID) in findClubById. All mutating operations (update, delete, join/leave, reset term, create membership, etc.) strictly validate and accept UUIDs only—any non-UUID will be rejected. The controller’s use of req.params.clubUuid (and membershipUuid) is consistent with this design.

Please confirm whether you intend to:

  • Restrict all write operations to UUIDs (no change required),
  • Or extend numeric-ID support across mutating methods.

If you choose the latter, you’ll need to update these service methods to handle numeric IDs similarly to findClubById:

• services/clubService.js – updateClub, deleteClub, getAllClubMemberships, createMembership, joinClub, leaveClub, resetClubTerm
• controllers/clubController.js – corresponding endpoints using req.params.clubUuid

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