From 4ea0f4fcddc378ccda0e5740e67b9722f53346a5 Mon Sep 17 00:00:00 2001 From: DongGeon0908 Date: Mon, 26 Aug 2024 23:49:35 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20ws=20group=20score=20ranking=20=EC=B2=98?= =?UTF-8?q?=EB=A6=AC=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../hero/alignlab/ws/model/GroupUserEventMessage.kt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/kotlin/com/hero/alignlab/ws/model/GroupUserEventMessage.kt b/src/main/kotlin/com/hero/alignlab/ws/model/GroupUserEventMessage.kt index 128d8e9..0635597 100644 --- a/src/main/kotlin/com/hero/alignlab/ws/model/GroupUserEventMessage.kt +++ b/src/main/kotlin/com/hero/alignlab/ws/model/GroupUserEventMessage.kt @@ -32,16 +32,20 @@ data class GroupUserEventMessage( return GroupUserEventMessage( groupId = groupId, groupUsers = userInfoByUid.mapNotNull { (uid, info) -> - val groupUSer = groupUserById[uid] ?: return@mapNotNull null + val groupUser = groupUserById[uid] ?: return@mapNotNull null ConcurrentUser( - groupUserId = groupUSer.id, + groupUserId = groupUser.id, uid = uid, nickname = info.nickname, - rank = rank.getAndIncrement(), + rank = -1, score = scoreByUid[uid]?.score ?: 0, ) - } + }.sortedBy { groupScore -> + groupScore.score + }.map { groupScore -> + groupScore.copy(rank = rank.getAndIncrement()) + }.take(5) ) } }