Skip to content

Commit

Permalink
imp: 집계 처리 진행시, 전체 데이터를 동기화
Browse files Browse the repository at this point in the history
  • Loading branch information
DongGeon0908 committed Sep 27, 2024
1 parent 96aab64 commit 7611c3c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ import java.io.Serializable
/** 집계 데이터를 관리 */
@JsonIgnoreProperties(ignoreUnknown = true)
data class PoseTotalCount(
val count: MutableMap<PoseType, Int> = mutableMapOf(),
val count: Map<PoseType, Int> = mutableMapOf(),
) : Serializable
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.hero.alignlab.domain.pose.application.PoseKeyPointSnapshotService
import com.hero.alignlab.domain.pose.application.PoseSnapshotService
import com.hero.alignlab.domain.pose.domain.PoseCount
import com.hero.alignlab.domain.pose.domain.PoseKeyPointSnapshot
import com.hero.alignlab.domain.pose.domain.vo.PoseTotalCount
import com.hero.alignlab.domain.pose.domain.vo.PoseType.Companion.BAD_POSE
import com.hero.alignlab.event.model.LoadPoseSnapshot
import com.hero.alignlab.ws.handler.ReactiveGroupUserWebSocketHandler
Expand Down Expand Up @@ -42,15 +43,16 @@ class PoseSnapshotListener(

val targetDate = event.poseSnapshot.createdAt.toLocalDate()

val poseSnapshot = poseSnapshotService.countByUidsAndDate(listOf(event.poseSnapshot.uid), targetDate)
.associate { snapshot -> snapshot.type to snapshot.count.toInt() }

/** 집계 데이터 처리 */
val poseCount = poseCountService.findByUidAndDateOrNull(event.poseSnapshot.uid, targetDate)
?: PoseCount(uid = event.poseSnapshot.uid, date = targetDate)

/** 집계 데이터 다시 조회하여, 동기화 진행 */
val updatedPoseCount = poseCount.apply {
val type = event.poseSnapshot.type

val typeCount = this.totalCount.count[type] ?: 0
this.totalCount.count[type] = typeCount + 1
this.totalCount = PoseTotalCount(count = poseSnapshot)
}

/** 포즈에 연관된 데이터 처리 */
Expand Down

0 comments on commit 7611c3c

Please sign in to comment.