Skip to content

Commit 264fa96

Browse files
committed
누락된 파일 커밋
누락된 파일 커밋
1 parent 36f360e commit 264fa96

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

backend/core/services/activity_service.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import logging
22
from django.db.models import Sum, Max
33
from django.db import transaction
4-
from core.models import UserActivity, UserSolvedProblem, UserProgress, PracticeDetail
4+
from core.models import UserActivity, UserSolvedProblem, UserProgress, PracticeDetail, UserWarsScore
55

66
logger = logging.getLogger(__name__)
77

@@ -38,12 +38,20 @@ def save_user_problem_record(user_profile, detail_id, score, submitted_data):
3838
# [2026-02-18 상세] 2. 누적 포인트 업데이트
3939
# - 단순 합산이 아닌, 동일 문제에 대해 여러 번 기록이 있을 경우 '최고 점수'만 반영함
4040
# - values('practice_detail')로 그룹화하여 문제별 Max 점수를 구한 뒤 최종 합산(Sum)함
41-
total_points_data = UserSolvedProblem.objects.filter(user=user_profile) \
41+
practice_points_data = UserSolvedProblem.objects.filter(user=user_profile) \
4242
.values('practice_detail') \
4343
.annotate(max_score=Max('score')) \
4444
.aggregate(total=Sum('max_score'))
45-
46-
total_points = total_points_data['total'] or 0
45+
practice_points = practice_points_data['total'] or 0
46+
47+
# [2026-03-04] Wars 게임 점수도 합산 (game_type별 최고점)
48+
wars_points_data = UserWarsScore.objects.filter(user=user_profile) \
49+
.values('game_type') \
50+
.annotate(max_score=Max('score')) \
51+
.aggregate(total=Sum('max_score'))
52+
wars_points = wars_points_data['total'] or 0
53+
54+
total_points = practice_points + wars_points
4755

4856
# [2026-02-18 상세] 유저 활동 정보(UserActivity) 갱신 또는 생성
4957
activity, _ = UserActivity.objects.get_or_create(user=user_profile)

0 commit comments

Comments
 (0)