-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
US10: Add "Most Followers" tab to display all users ranked by their followers #37
Conversation
These 2 tpl files were initially ignored. However, we need to track them for front-end changes.
We want to display the number of followers users have under the tab of most followers.
We have the number showing correctly now, but we need to sort it in the correct order. So, we dived deep into the logic of the top poster and tried to copy the logic of it to the most popular in the file followe.js.
This file was ignored by nodebb, and we are trying to keep it tracked.
Pull Request Test Coverage Report for Build 11239532554Details
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The newly added code looks pretty clean and organized to me! The test cases for this us10 also covers edges cases I can think of, thanks Justin and Ethan!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code respects existing structure, new features in code blend well with current design, tests work good and cover different scenarios
Overview
This pull request implements User Story 10: “As a user, I want to see the most popular users across all users on the ‘Users’ page, so that I can have a better idea of who has the most followers on NodeBB.” We have added a new tab called "Most Followers" on the Users page, displaying users sorted by their follower count in descending order.
Features Implemented
1. Frontend Changes
2. Backend Changes
Schema Updates: we updated the schema in the YAML files to include a new attribute
followerCount
for each user. This attribute is used to store the total number of followers a user has, which allows efficient retrieval and sorting when fetching user data.Controller Modifications
(1) Sorting Logic: Modified the controller logic to sort users based on the
followerCount
attribute. This ensures that users are correctly ordered by the number of followers they have when the "Most Followers" tab is accessed.(2) New Endpoint: Introduced a new API endpoint (
/api/users?section=sort-followers
) specifically for retrieving users sorted by their follower count.(3) Database Query Adjustments: Updated database queries to retrieve and sort users based on the new
followerCount
field, ensuring that the sorting remains efficient even with a large number of users.Follower Count Management
(1) Increment/Decrement Operations: Adjusted the code to update the
followerCount
value whenever a user follows or unfollows another user. The logic now correctly increments or decrements the count, and the value is stored back in the database for consistency.(2) Bulk Update Function: Implemented a function (
updateFollowerCount
) that efficiently updates the follower count for multiple users at once. This is particularly useful for scenarios where multiple follow/unfollow events occur in a short period.Test Coverage
Solves: #27 #28 #29 #35 #36
Screenshot