Skip to content

Conversation

@seoin2744
Copy link
Contributor

@seoin2744 seoin2744 commented Nov 18, 2025

Description

대회 종료 후 특정 대회의 특정 문제에 대한 통계 그래프 데이터를 조회할 수 있는 API

<기능>

  1. 오답 분포 통계 (Distribution)

    • 문제에 대한 제출 결과 유형별 분포 그래프
    • 지원하는 결과 유형: WA, TLE, MLE, RE, CE, ETC
      • WA ← WrongAnswer
      • TLE ← TimeLimitExceeded
      • MLE ← MemoryLimitExceeded
      • RE ← RuntimeError + SegmentationFaultError
      • CE ← CompileError
      • ETC ← ServerError + OutputLimitExceeded
    • 총 제출 수와 각 결과 유형별 제출 수를 반환함.
  2. 시간별 제출 추이 통계 (Timeline)

    • 대회 기간을 6등분하여 각 시간대별 제출 추이 그래프
    • 타임슬롯 간격은 대회 시간에 따라 동적으로 결정됨 (예: 3시간 대회 → 30분, 6시간 대회 → 60분)
    • 각 시간 슬롯별로 Accepted 제출 수와 Wrong 제출 수(WA/TLE/MLE/RE/CE/ETC의 합)를 집계함.
    • 타임스탬프는 ISO8601 형식으로 반환됨.
  3. 모드 선택 기능

    • mode 쿼리 파라미터를 통해 원하는 통계만 선택적으로 조회할 수 있습니다
    • mode=distribution: 오답 분포만 반환
    • mode=timeline: 시간별 제출 추이만 반환
    • mode 미지정 시: 두 통계 모두 반환 (both)

접근 정책:

  • 대회 종료 후에만 조회 가능 (대회 종료 전 접근 시 ForbiddenAccessException 발생)
  • 인증 불필요 (대회 종료 후 누구나 접근 가능)
  • 대회에 속한 문제인지 검증 후 통계 데이터 반환

Additional context

  • StatisticsModeValidationPipe를 추가하여 mode 쿼리 파라미터의 유효성을 검증
  • 대회 시작 시간과 종료 시간을 기반으로 타임라인을 6등분하여 슬롯을 생성
  • 실제 사용자의 제출만 집계.
  • 시드 데이터를 추가하여 스테이지에서 확인할 수 있게 함.

Before submitting the PR, please make sure you do the following

@skkuding-bot
Copy link

skkuding-bot bot commented Nov 18, 2025

Syncing Preview App Succeeded

Application: frontend
Revision: 0e51eba9da20b10d1f0980548b0f00e1be9cda50
Health Status: Healthy

Open Preview | View in Argo CD

@seoin2744 seoin2744 changed the title contest problem statistics graph feat(be): contest problem statistics graph Nov 18, 2025
@skkuding-bot
Copy link

skkuding-bot bot commented Nov 20, 2025

Syncing Preview App Succeeded

Application: frontend
Revision: ae254da4fa345686c945bcf9de70faa7e326b96c
Health Status: Healthy

Open Preview | View in Argo CD

@skkuding-bot
Copy link

skkuding-bot bot commented Nov 20, 2025

Syncing Preview App Succeeded

Application: frontend
Revision: e275d1e7400e8799c1d1d6996430ed358410a5d8
Health Status: Healthy

Open Preview | View in Argo CD

@skkuding-bot
Copy link

skkuding-bot bot commented Nov 20, 2025

Syncing Preview App Succeeded

Application: frontend
Revision: b82ef258a815b725720a9eb4d99ca7d8615cf86a
Health Status: Healthy

Open Preview | View in Argo CD

Copy link
Contributor

@hjkim24 hjkim24 left a comment

Choose a reason for hiding this comment

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

일단 컨트롤러랑 서비스 부분만 봤어요! 수정 부탁드립니당

})
}

@Get(':problemId/statistics/graph')
Copy link
Contributor

Choose a reason for hiding this comment

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

저희 대회에 대한 통계니까 Problem 쪽이 아니라 Contest 쪽에 두는게 맞을 것 같아요! 컨트롤러랑 서비스 모두 옮겨주세요

mode?: 'distribution' | 'timeline'
}) {
// 대회가 종료된 상태인지 확인
const contest = await this.prisma.contest.findUniqueOrThrow({
Copy link
Contributor

Choose a reason for hiding this comment

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

findUniqueOrThrow를 쓰면 404에 대한 에러 처리가 깔끔하지 않아서 findUnique나 First로 찾고 !contest로 EntityNotExist 예외 처리 던져주는게 더 좋을 것 같아요!

)
}

if (!contest.startTime) {
Copy link
Contributor

Choose a reason for hiding this comment

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

이렇게 하면 큰 의미가 있는건지 잘 모르겠어요..

}

// 대회 소속 문제 검증
await this.prisma.contestProblem.findUniqueOrThrow({
Copy link
Contributor

Choose a reason for hiding this comment

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

이것도 위에랑 마찬가지!

async getContestProblemStatistics({
contestId,
problemId,
mode
Copy link
Contributor

Choose a reason for hiding this comment

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

mode를 두신 이유가 무엇일까요? 오답 유형 분포랑 문제별 타임라인은 무조건 같이 보여주는 걸로 알고 있는데

@Get(':problemId/statistics/graph')
@UserNullWhenAuthFailedIfPublic()
async getContestProblemStatistics(
@Req() req: AuthenticatedRequest,
Copy link
Contributor

Choose a reason for hiding this comment

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

사용하지 않는 파라미터 삭제해주세요!

@skkuding-bot
Copy link

skkuding-bot bot commented Nov 21, 2025

Syncing Preview App Succeeded

Application: frontend
Revision: 3e97de4fd8198ca83b17704e5797d80da62fece2
Health Status: Healthy

Open Preview | View in Argo CD

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.

3 participants