Skip to content

[admin] 배지 관리 CRUD + 레벨/미션/배지 운영 통계 API#264

Merged
Develop-KIM merged 3 commits into
developfrom
feat/admin-badge-mission-management
Jun 30, 2026
Merged

[admin] 배지 관리 CRUD + 레벨/미션/배지 운영 통계 API#264
Develop-KIM merged 3 commits into
developfrom
feat/admin-badge-mission-management

Conversation

@Develop-KIM

Copy link
Copy Markdown
Member

작업 내용 ([핵심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 배지별 획득 현황

정책

  • 배지 = 파라미터형 CRUD(conditionType+threshold+params). 조건타입은 코드 제공 고정 메뉴.
  • 레벨/미션 = 통계 조회만 (정의 편집 불가, 닫힌 사다리). 미션 임계값/조건은 진행 중 유저 상태 정합성 때문에 런타임 CRUD 대신 코드+마이그레이션으로 관리.

도메인/인프라

  • Badgeupdate/changeActive 추가, 편집 필드 var 전환
  • BadgeRepository.findById, UserLevelRepository.countGroupByLevel, UserMissionRepository.countGroupByLevelAndStatus 추가

테스트

  • AdminBadgeApi/AdminAchievementStatsApi REST Docs, AdminBadgeManagementService/AdminAchievementStatsService 단위 테스트

🤖 Generated with Claude Code

- 배지 생성/수정/활성토글 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>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +16 to +17
"SELECT ul.currentLevel AS level, COUNT(ul) AS count FROM UserLevel ul " +
"GROUP BY ul.currentLevel ORDER BY ul.currentLevel",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +87 to +90
return BadgeCondition(
conditionType = parseConditionType(conditionType),
threshold = threshold,
params = params?.takeIf { it.isNotEmpty() },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Develop-KIM and others added 2 commits June 30, 2026 13:33
프론트엔드 숫자 변환 규칙(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>
@Develop-KIM Develop-KIM merged commit 9d5c01f into develop Jun 30, 2026
1 check passed
@Develop-KIM Develop-KIM deleted the feat/admin-badge-mission-management branch July 1, 2026 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant