Skip to content

Conversation

@Boy132
Copy link
Member

@Boy132 Boy132 commented Nov 4, 2025

Closes #1733

@Boy132 Boy132 self-assigned this Nov 4, 2025
@coderabbitai
Copy link

coderabbitai bot commented Nov 4, 2025

📝 Walkthrough

Walkthrough

A distinct clause is added to the directAccessibleServers query in the User model to eliminate duplicate server entries when users have viewAny permission. The clause ensures unique server IDs by filtering out duplicates produced by join operations with subusers.

Changes

Cohort / File(s) Summary
Query Fix
app/Models/User.php
Added ->distinct('servers.id') to the directAccessibleServers query to remove duplicate server rows from join operations

Pre-merge checks

✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding a distinct clause to fix duplicate returns in the directAccessibleServers query.
Description check ✅ Passed The description references the linked issue #1733, which is directly related to the duplicate servers problem being fixed by this changeset.
Linked Issues check ✅ Passed The code change adds a distinct() clause to eliminate duplicate server rows caused by joins, directly addressing the duplicate servers UI issue reported in #1733.
Out of Scope Changes check ✅ Passed The change is limited to the directAccessibleServers query method in User.php, which is directly scoped to fixing the duplicate servers issue without introducing unrelated modifications.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 852f7be and 16c81d6.

📒 Files selected for processing (1)
  • app/Models/User.php (1 hunks)
🔇 Additional comments (1)
app/Models/User.php (1)

284-292: LGTM! Fix correctly addresses duplicate server listings.

The addition of ->distinct('servers.id') properly eliminates duplicate rows from the left join with the subusers table. Database verification confirms the subusers table has no unique constraint on the (user_id, server_id) combination, which allows duplicate records to exist. This, combined with the OR conditions in the WHERE clause, can produce duplicate results when the same server matches through multiple paths (e.g., user is both owner and subuser, or duplicate subuser records exist).

The fix is consistent with the accessibleServers() method (line 274), which already applies the same distinct pattern.


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@Boy132 Boy132 merged commit e0c4e47 into main Nov 5, 2025
25 checks passed
@Boy132 Boy132 deleted the boy132/fix-duplicate-servers branch November 5, 2025 15:19
@github-actions github-actions bot locked and limited conversation to collaborators Nov 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Duplicate servers in UI

3 participants