Skip to content
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

Fix/issue 400 #461

Merged
merged 4 commits into from
Nov 11, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion router/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,20 @@ func (h *Handlers) HandleGetMeGroupIDs(c echo.Context) error {
return judgeErrorResponse(err)
}

groupIDs = append(belongingGroupIDs, adminGroupIDs...)
uniqueIDs := make(map[uuid.UUID]struct{})

for _, id := range belongingGroupIDs {
uniqueIDs[id] = struct{}{}
}

for _, id := range adminGroupIDs {
uniqueIDs[id] = struct{}{}
}

for id := range uniqueIDs {
groupIDs = append(groupIDs, id)
}
Copy link
Member

Choose a reason for hiding this comment

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

allGroupIDs := append(belongingGroupIDs, adminGroupIDs)

uniqueIDMap := make(map[uuid.UUID]struct{})
uniqueIDs := make([]uuid.UUID, 0, len(allGroupIDs))
for _, id := range allGroupIDs {
    if _, ok := uniqueIDMap[id]; ok {
        continue
    }

    uniqueIDMap[id] = struct{}{}
    uniqueIDs = append(uniqueIDs, id)
}

みたいに書けそうです:eyes:


Copy link
Member

Choose a reason for hiding this comment

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

最後の空行は消してもらえると助かります:pray:

}

return c.JSON(http.StatusOK, groupIDs)
Expand Down