[admin] 배지 관리 CRUD + 레벨/미션/배지 운영 통계 API#264
Conversation
- 배지 생성/수정/활성토글 API (POST/PUT/PATCH) + 감사로그 - 배지 상세 조회, condition-types 메타(조건타입 7종/카테고리 4종 + param 스키마) API - 레벨 분포/미션 달성/배지 획득 운영 통계 API (/admin/stats/levels·missions·badges) - Badge 도메인에 update/changeActive 추가, 편집 필드 var 전환 - BadgeRepository.findById, UserLevel/UserMission 집계 쿼리 추가 - 미션/레벨은 통계 조회만 (닫힌 사다리, CRUD 미제공) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c7612d671d
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| "SELECT ul.currentLevel AS level, COUNT(ul) AS count FROM UserLevel ul " + | ||
| "GROUP BY ul.currentLevel ORDER BY ul.currentLevel", |
There was a problem hiding this comment.
Count level-one users without UserLevel rows
When /api/v1/admin/stats/levels is used in production, users who have signed up/onboarded but have not completed their first retrospective are omitted because UserLevel rows are created lazily in MissionProgressService.updateProgressOnRetroComplete, yet this query counts only existing user_levels rows. Since UserLevel defaults to level 1, the level distribution undercounts level-1 users and the dashboard total; count active users with a left join/default level 1 or create the level row during registration.
Useful? React with 👍 / 👎.
| return BadgeCondition( | ||
| conditionType = parseConditionType(conditionType), | ||
| threshold = threshold, | ||
| params = params?.takeIf { it.isNotEmpty() }, |
There was a problem hiding this comment.
Reject unsupported weeklyMinCount values
When an admin creates or updates a WEEKLY_STREAK badge with params.weeklyMinCount set to anything other than 1 or 3, the badge is saved successfully here but BadgeConditionChecker.checkWeeklyStreak returns false for unsupported values, so the badge can never be awarded. The CRUD path should either validate the param against the supported values or implement counting for arbitrary values before persisting it.
Useful? React with 👍 / 👎.
프론트엔드 숫자 변환 규칙(type==number/integer)과 일치시켜 weeklyMinCount가 문자열이 아닌 숫자로 전송되도록 함. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- 레벨 분포 통계: UserLevel 행이 lazy 생성되어 첫 회고 전 유저가 누락되던 문제 → 행 없는 유저를 레벨 1로 집계(UserRepository.countByDeletedAtIsNull 기준) - WEEKLY_STREAK 배지 생성/수정 시 weeklyMinCount를 1 또는 3으로 검증 (평가기가 1·3만 지원하므로 그 외 값은 영영 미부여 방지) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
작업 내용 ([핵심5] 관리자 배지 CRUD + 통계)
배지 관리 (CRUD)
POST /api/v1/admin/badges생성PUT /api/v1/admin/badges/{badgeId}수정PATCH /api/v1/admin/badges/{badgeId}/active활성/비활성 (삭제 대신 active=false, 획득 데이터 보존)GET /api/v1/admin/badges/{badgeId}상세GET /api/v1/admin/badges/condition-types조건타입 7종 + 카테고리 4종 + param 스키마(드롭다운용)GET /badges(목록),GET /badges/{id}/holders(획득자) 유지 — 목록 응답을 category/threshold/params/active/iconUrl/congrats로 확장ADMIN_BADGE_CREATED/UPDATED/ACTIVE_CHANGED)운영 통계
GET /api/v1/admin/stats/levels레벨 분포(1~10)GET /api/v1/admin/stats/missions레벨별 미션 진행/완료/실패 + 완료율GET /api/v1/admin/stats/badges배지별 획득 현황정책
도메인/인프라
Badge에update/changeActive추가, 편집 필드 var 전환BadgeRepository.findById,UserLevelRepository.countGroupByLevel,UserMissionRepository.countGroupByLevelAndStatus추가테스트
🤖 Generated with Claude Code