-
Notifications
You must be signed in to change notification settings - Fork 0
FIX: proper handling of group memberships #3
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
base: group-dm-user-addition-pre
Are you sure you want to change the base?
FIX: proper handling of group memberships #3
Conversation
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.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Greptile OverviewConfidence Score: 2/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Admin as Admin UI
participant Controller as admin-group.js.es6
participant Model as group.js
participant Backend as groups_controller.rb
participant DB as Database
Note over Admin,DB: Add Member Flow
Admin->>Controller: addMembers(usernames)
Controller->>Model: addMembers(usernames)
Model->>Backend: PUT /admin/groups/:id/members.json
Backend->>DB: group.add(user)
Backend-->>Model: success_json
Model->>Backend: GET /groups/:name/members.json
Backend->>DB: group.users.limit().offset()
Backend-->>Model: {members, meta}
Model-->>Controller: Updated members list
Controller-->>Admin: UI refresh
Note over Admin,DB: Remove Member Flow
Admin->>Controller: removeMember(member)
Controller->>Model: removeMember(member)
Model->>Backend: DELETE /admin/groups/:id/members.json
Backend->>DB: group.users.delete(user_id)
Backend-->>Model: success_json
Model->>Backend: GET /groups/:name/members.json
Backend->>DB: group.users.limit().offset()
Backend-->>Model: {members, meta}
Model-->>Controller: Updated members list
Controller-->>Admin: UI refresh
Note over Admin,DB: Pagination Flow
Admin->>Controller: next() or previous()
Controller->>Model: set offset, findMembers()
Model->>Backend: GET /groups/:name/members.json?limit&offset
Backend->>DB: group.users.limit().offset()
Backend-->>Model: {members, meta}
Model-->>Controller: Updated page
Controller-->>Admin: Display new page
|
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.
16 files reviewed, 3 comments
| context ".remove_member" do | ||
|
|
||
| it "cannot remove members from automatic groups" do | ||
| xhr :put, :remove_member, group_id: 1, user_id: 42 |
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.
syntax: wrong HTTP method - test uses PUT but route expects DELETE
| xhr :put, :remove_member, group_id: 1, user_id: 42 | |
| xhr :delete, :remove_member, group_id: 1, user_id: 42 |
Prompt To Fix With AI
This is a comment left during a code review.
Path: spec/controllers/admin/groups_controller_spec.rb
Line: 115:115
Comment:
**syntax:** wrong HTTP method - test uses `PUT` but route expects `DELETE`
```suggestion
xhr :delete, :remove_member, group_id: 1, user_id: 42
```
How can I resolve this? If you propose a fix, please make it concise.| }, | ||
|
|
||
| destroy: function(){ | ||
| if (!this.get('id')) { return }; |
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.
logic: missing return statement - breaks promise chain
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/assets/javascripts/discourse/models/group.js
Line: 82:82
Comment:
**logic:** missing return statement - breaks promise chain
How can I resolve this? If you propose a fix, please make it concise.| if (this.get("showingLast")) { return; } | ||
|
|
||
| var group = this.get("model"), | ||
| offset = Math.min(group.get("offset") + group.get("limit"), group.get("user_count")); |
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.
logic: next calculation is incorrect - when on last page boundary with exact multiple of limit, this allows incrementing past total count
Prompt To Fix With AI
This is a comment left during a code review.
Path: app/assets/javascripts/admin/controllers/admin-group.js.es6
Line: 33:33
Comment:
**logic:** `next` calculation is incorrect - when on last page boundary with exact multiple of limit, this allows incrementing past total count
How can I resolve this? If you propose a fix, please make it concise.
Test 8
Replicated from ai-code-review-evaluation/discourse-greptile#8