Skip to content

Conversation

@JAHANWEE
Copy link

@JAHANWEE JAHANWEE commented Nov 6, 2025

Date: 7 Nov 2025

Developer Name: @JAHANWEE


Issue Ticket Number

Description

  • Fixed memberCount calculation in models/discordactions.js to include only users with in_discord: true.
  • Added filtering logic to fetch and count only active Discord members.
  • Ensured tests accurately reflect active vs inactive Discord users.

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

  • Yes
  • No

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

Screenshots

Screenshot 1
2025-11-07.08-59-41.mp4

Test Coverage

Details Screenshot 2025-11-07 050338 Screenshot 1

Additional Notes

@coderabbitai
Copy link

coderabbitai bot commented Nov 6, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Summary by CodeRabbit

  • Bug Fixes
    • Improved accuracy of group membership counts to reflect only users currently active in Discord, providing more reliable member tallies across groups.

Walkthrough

Refactored enrichGroupDataWithMembershipInfo to compute group member counts by first batching user document queries and filtering for users marked as in_discord, then counting only those mappings instead of all mappings. This ensures member counts reflect active Discord members rather than all historical user-mapping records.

Changes

Cohort / File(s) Summary
Membership enrichment logic
models/discordactions.js
Added batched user document fetches with in_discord filtering to determine which role-ID-to-count mappings contribute to member counts, replacing the prior unfiltered count logic.
Test updates
test/unit/models/discordactions.test.js
Updated expected memberCount for the first group result from 2 to 1, reflecting the new filtered-membership behavior; all other asserted fields remain unchanged.

Sequence Diagram(s)

sequenceDiagram
    participant fn as enrichGroupDataWithMembershipInfo
    participant db as User DB
    participant filter as in_discord Filter
    participant count as Count Aggregation

    fn->>db: Batch fetch user docs for all roleIds
    db-->>fn: Return user documents
    fn->>filter: Filter users where in_discord = true
    filter-->>fn: Filtered user set
    fn->>count: Count mappings for each roleId
    count-->>fn: roleIdToCountMap (filtered)
    fn-->>fn: Return groups with accurate memberCounts
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

  • Areas requiring attention:
    • Batch user fetch implementation and performance implications with large user counts
    • Filtering logic correctness—verify in_discord field is reliably set and reflects actual Discord membership status
    • Mapping between original groupsToUserMappings and filtered batch results to ensure no mappings are incorrectly skipped
    • Test coverage adequacy—ensure test data setup properly reflects Discord presence/absence scenarios

Possibly related issues

Poem

🐰 Hop along, dear Discord band,
No more phantom counts in the land!
We count only those here to stay,
Active members brightening the day.
Accurate now, our membership rings true—
A rabbit's delight in numbers renewed! 🥕

Pre-merge checks and finishing touches

✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: correcting memberCount to count only active members, which is the primary objective of this bugfix.
Linked Issues check ✅ Passed The PR successfully addresses issue #2495 by filtering memberCount to include only active Discord members marked with in_discord: true, directly resolving the inflated count issue.
Out of Scope Changes check ✅ Passed All changes are in scope: refactored memberCount logic in discordactions.js and updated corresponding tests to reflect active members only, directly addressing the linked issue.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description check ✅ Passed The PR description clearly describes the changes made to fix memberCount calculation by filtering for in_discord: true users and adding filtering logic.

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.

@korbit-ai
Copy link

korbit-ai bot commented Nov 6, 2025

I was unable to write a description for this pull request. This could be because I only found files I can't scan.

Copy link

@korbit-ai korbit-ai bot left a comment

Choose a reason for hiding this comment

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

Review by Korbit AI

Korbit automatically attempts to detect when you fix issues in new commits.
Category Issue Status
Performance Uncontrolled parallel database queries ▹ view
Performance Inefficient array operation chaining ▹ view
Files scanned
File Path Reviewed
models/discordactions.js

Explore our documentation to understand the languages and file types we support and the files we ignore.

Check out our docs on how you can make Korbit work best for you and your team.

Loving Korbit!? Share us on LinkedIn Reddit and X

@JAHANWEE JAHANWEE closed this Nov 15, 2025
@iamitprakash iamitprakash reopened this Nov 15, 2025
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.

Group Page Revamp — Accurate Member Count

5 participants