Skip to content

Commit

Permalink
fix: put logined user on top of the list
Browse files Browse the repository at this point in the history
  • Loading branch information
aiaiaiai1 committed Jul 24, 2024
1 parent 0272ebd commit da3c1d6
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/java/gymmi/service/WorkspaceService.java
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,21 @@ private void deleteTaskAndWorker(User loginedUser, Long workspaceId) {
}

public InsideWorkspaceResponse enterWorkspace(User logiendUser, Long workspaceId) {
validateIfWorkerIsInWorkspace(logiendUser.getId(), workspaceId);
Worker worker = validateIfWorkerIsInWorkspace(logiendUser.getId(), workspaceId);

Workspace workspace = workspaceRepository.getWorkspaceById(workspaceId);
List<Worker> sortedWorkers = workerRepository.getAllByWorkspaceIdOrderByContributedScore(workspaceId);

List<Integer> workerRanks = rankTied(sortedWorkers);
List<Worker> workers = sortedWorkers.stream()
.filter(w -> !w.equals(worker))
.toList();
workers.add(0, worker);

List<Integer> workerRanks = rankTied(workers);
// hot-fix
int achievementScore = workspaceRepository.getAchievementScore(workspaceId);


return InsideWorkspaceResponse.builder()
.workspace(workspace)
.achievementScore(achievementScore)
Expand Down

0 comments on commit da3c1d6

Please sign in to comment.