From da3c1d6b923ad9d93fa6f1d589558da18014e8aa Mon Sep 17 00:00:00 2001 From: aiaiaiai1 Date: Wed, 24 Jul 2024 23:35:52 +0900 Subject: [PATCH] fix: put logined user on top of the list --- src/main/java/gymmi/service/WorkspaceService.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/gymmi/service/WorkspaceService.java b/src/main/java/gymmi/service/WorkspaceService.java index 113879c..e588347 100644 --- a/src/main/java/gymmi/service/WorkspaceService.java +++ b/src/main/java/gymmi/service/WorkspaceService.java @@ -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 sortedWorkers = workerRepository.getAllByWorkspaceIdOrderByContributedScore(workspaceId); - List workerRanks = rankTied(sortedWorkers); + List workers = sortedWorkers.stream() + .filter(w -> !w.equals(worker)) + .toList(); + workers.add(0, worker); + + List workerRanks = rankTied(workers); + // hot-fix int achievementScore = workspaceRepository.getAchievementScore(workspaceId); + return InsideWorkspaceResponse.builder() .workspace(workspace) .achievementScore(achievementScore)