Skip to content

Commit

Permalink
fix: 그룹 스코어 처리 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
DongGeon0908 committed Sep 3, 2024
1 parent e3f561b commit 963e9be
Showing 1 changed file with 18 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import com.hero.alignlab.common.extension.coExecuteOrNull
import com.hero.alignlab.config.database.TransactionTemplates
import com.hero.alignlab.domain.group.application.GroupUserScoreService
import com.hero.alignlab.domain.group.application.GroupUserService
import com.hero.alignlab.domain.group.domain.GroupUserScore
import com.hero.alignlab.domain.pose.application.PoseCountService
import com.hero.alignlab.domain.pose.application.PoseKeyPointSnapshotService
import com.hero.alignlab.domain.pose.domain.PoseCount
Expand Down Expand Up @@ -55,15 +56,26 @@ class PoseSnapshotListener(
.values
.sum()

/** group score 처리 */
val groupUser = groupUserService.findByUid(event.poseSnapshot.uid)
val groupUserScore = groupUserScoreService.findByUidOrNull(event.poseSnapshot.uid)
val updatedGroupUserScore = when (groupUser == null) {
true -> null
false -> {
val groupUserScore = groupUserScoreService.findByUidOrNull(event.poseSnapshot.uid)

val updatedGroupUserScore = when (groupUser != null && groupUserScore != null) {
true -> groupUserScore.apply {
this.score = score
}
when (groupUserScore != null) {
true -> groupUserScore.apply {
this.score = score
}

false -> null
false -> GroupUserScore(
groupId = groupUser.groupId,
groupUserId = groupUser.id,
uid = groupUser.uid,
score = score
)
}
}
}

txTemplates.writer.coExecuteOrNull {
Expand Down

0 comments on commit 963e9be

Please sign in to comment.