Skip to content

Conversation

@akshayutture-augment
Copy link

@akshayutture-augment akshayutture-augment commented Nov 14, 2025

Test 8


Replicated from ai-code-review-evaluation/discourse-cursor#8


Note

Implements paginated group members with admin UI to add/remove users and corresponding backend endpoints, replacing username-passing on save/create.

  • Frontend (Admin/Client):
    • Paginated members in admin-group controller/model (limit/offset/user_count, currentPage/totalPages, next/previous actions).
    • New member management UI in admin/templates/group.hbs with list, pagination controls, and add/remove actions; new group-member view/template.
    • Group model: findMembers() consumes /members.json with meta; new addMembers(usernames) and removeMember(member); create/save no longer take usernames.
    • Routes/controllers load members on setup (admin_group_route, group-members route). Templates adjusted to use members.
  • Backend:
    • GroupsController#members now returns JSON with members and meta { total, limit, offset } and supports pagination.
    • Admin::GroupsController: new create/update param shape, ILIKE search; new add_members and remove_member actions; forbid modifying automatic groups; simplified destroy.
  • Routes:
    • Added PUT /admin/groups/members (add_members) and DELETE /admin/groups/members (remove_member).
  • UI/Styles & I18n:
    • Styling for groups form, member list, and controls in admin_base.scss.
    • Copy tweaks and new keys (e.g., selector_placeholder, add/remove confirmations/labels).
  • Tests:
    • Updated specs for new endpoints and behaviors (create stripping, ignore rename on automatic, add/remove members, refresh automatic).

Written by Cursor Bugbot for commit 060cda7. Configure here.

@akshayutture-augment
Copy link
Author

cursor review

end

def add_members
group = Group.find(params.require(:group_id).to_i)
Copy link

Choose a reason for hiding this comment

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

Bug: Incorrect ID Parameter Halts Group Management.

The add_members method expects params[:group_id] but the route is defined as a member route under resources :groups, which provides the group ID as params[:id] instead. This causes the endpoint to fail when called from the frontend.

Fix in Cursor Fix in Web


return can_not_modify_automatic if group.automatic

group.users.delete(user_id)
Copy link

Choose a reason for hiding this comment

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

Bug: ActiveRecord Delete: Object Parameter Mismatch

The delete method on ActiveRecord associations expects an object or array of objects, not an ID. Passing user_id directly will not remove the user from the group. This should use group.users.delete(User.find(user_id)) or a similar approach that passes the actual user object.

Fix in Cursor Fix in Web

totalPages: function() {
if (this.get("user_count") == 0) { return 0; }
return Math.floor(this.get("user_count") / this.get("limit")) + 1;
}.property("limit", "user_count"),
Copy link

Choose a reason for hiding this comment

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

Bug: Pagination Error: Extra Empty Page Appears

The totalPages calculation uses Math.floor(user_count / limit) + 1, which incorrectly returns 3 pages when user_count is exactly 100 and limit is 50 (should be 2 pages). This causes an empty third page to appear. The formula should use Math.ceil(user_count / limit) instead.

Fix in Cursor Fix in Web

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.

3 participants