Skip to content

Commit

Permalink
feat(Tag): Sort tags when requested
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreykwan committed Apr 4, 2024
1 parent 44c3d0e commit 8c5c7d4
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.wise.portal.presentation.web.controllers.tag;

import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -43,7 +44,10 @@ protected ResponseEntity<Map<String, Object>> createTag(Authentication auth,
@GetMapping("/user/tags")
protected ResponseEntity<List<Map<String, Object>>> getTags(Authentication auth) {
User user = userService.retrieveUserByUsername(auth.getName());
List<Map<String, Object>> tags = userTagsService.getTags(user).stream().map(tag -> {
List<UserTag> userTags = userTagsService.getTags(user);
Collections.sort(userTags,
(tag1, tag2) -> tag1.getText().toLowerCase().compareTo(tag2.getText().toLowerCase()));
List<Map<String, Object>> tags = userTags.stream().map(tag -> {
return tag.toMap();
}).collect(Collectors.toList());
return ResponseEntityGenerator.createSuccess(tags);
Expand Down

0 comments on commit 8c5c7d4

Please sign in to comment.