Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.stream.Collectors;

import org.ezcode.codetest.domain.problem.model.entity.Problem;
import org.ezcode.codetest.domain.problem.model.enums.Difficulty;
import org.ezcode.codetest.domain.submission.model.entity.Submission;

import com.fasterxml.jackson.annotation.JsonPropertyOrder;
Expand All @@ -13,7 +14,7 @@
import lombok.Getter;

@Getter
@JsonPropertyOrder({"problemId", "problemTitle", "problemDescription", "submissions"})
@JsonPropertyOrder({"problemId", "problemTitle","problemDifficulty", "problemDescription", "submissions"})
@Schema(description = "문제 단위로 묶은 제출 목록 응답")
public class GroupedSubmissionResponse {

Expand All @@ -23,6 +24,9 @@ public class GroupedSubmissionResponse {
@Schema(description = "문제 제목", example = "A + B")
private final String problemTitle;

@Schema(description = "문제 난이도", example = "LV1")
private final Difficulty problemDifficulty;

@Schema(description = "문제 설명", example = "두 수의 합을 구하는 문제입니다.")
private final String problemDescription;

Expand All @@ -49,6 +53,7 @@ private static GroupedSubmissionResponse createSorted(Problem problem, List<Subm
private GroupedSubmissionResponse(Problem problem, List<Submission> submissions) {
this.problemId = problem.getId();
this.problemTitle = problem.getTitle();
this.problemDifficulty = problem.getDifficulty();
this.problemDescription = problem.getDescription();
this.submissions = submissions.stream()
.map(SubmissionDetailResponse::from)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ public record SubmissionDetailResponse(
@Schema(description = "제출 ID", example = "101")
Long id,

@Schema(description = "제출 언어", example = "Java(17)")
String language,
Comment on lines +15 to +16
Copy link

@coderabbitai coderabbitai bot Jul 26, 2025

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

스키마 예시와 실제 구현 간 불일치를 확인해주세요.

스키마 예시에서는 "Java(17)"로 괄호를 포함하고 있지만, Submission.getLanguageInfo() 메서드는 괄호 없이 단순 연결하고 있습니다.

실제 반환 형식을 확인해보세요:


🏁 Script executed:

#!/bin/bash
# 언어 엔티티의 getName()과 getVersion() 메서드 반환 형식 확인
ast-grep --pattern 'class Language {
  $$$
  getName() {
    $$$
  }
  $$$
  getVersion() {
    $$$
  }
  $$$
}'

Length of output: 114


getLanguageInfo() 메서드 구현을 찾아 실제 반환 형식을 확인해보겠습니다:


🏁 Script executed:

#!/usr/bin/env bash
# Submission 엔티티에서 getLanguageInfo() 메서드 구현 찾아 반환 형식 확인
rg -n "getLanguageInfo" src

Length of output: 305


다음으로 getLanguageInfo() 메서드의 실제 구현을 확인하겠습니다.


🏁 Script executed:

#!/usr/bin/env bash
# getLanguageInfo() 메서드 본문 확인
rg -n -A5 "public String getLanguageInfo" src/main/java/org/ezcode/codetest/domain/submission/model/entity/Submission.java

Length of output: 347


언어 정보 포맷 일관화 필요

현재 Submission.getLanguageInfo()

return language.getName() + language.getVersion();  // "Java17"

형태로 반환하지만, DTO의

@Schema(description = "제출 언어", example = "Java(17)")

예시는 괄호를 포함한 "Java(17)" 형식입니다. 아래 중 하나로 정리해주세요:

  • Submission 엔티티의 getLanguageInfo()
     public String getLanguageInfo() {
  •  return language.getName() + language.getVersion();
    
  •  return language.getName() + "(" + language.getVersion() + ")";
    
    }
    로 변경  
    
  • 또는 SubmissionDetailResponse.java의 스키마 예시를
     @Schema(description = "제출 언어", example = "Java(17)")
  • String language,
  • String language, // example = "Java17"
    와 같이 `"Java17"`로 수정
    
    
🤖 Prompt for AI Agents
In
src/main/java/org/ezcode/codetest/application/submission/dto/response/submission/SubmissionDetailResponse.java
around lines 15 to 16, the language format in the schema example ("Java(17)") is
inconsistent with the Submission entity's getLanguageInfo() method, which
returns "Java17" without parentheses. To fix this, either update the
getLanguageInfo() method in the Submission entity to include parentheses around
the version (e.g., "Java(17)"), or change the schema example in
SubmissionDetailResponse.java to match the current format "Java17" without
parentheses for consistency.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

애초에 version이 (17) 이렇게 들어가있어

Copy link

Choose a reason for hiding this comment

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

🧩 Analysis chain

@thezz9 말씀이 맞네요! Language 엔티티의 version 필드가 이미 "(17)" 형태로 괄호를 포함하고 있다면, getName() + getVersion()"Java(17)"을 반환하므로 스키마 예시와 일치합니다.

제가 잘못 분석했습니다. 현재 구현이 올바르게 되어 있네요.


🏁 Script executed:

#!/bin/bash
# Language 엔티티의 구조를 확인하여 version 필드 형식을 파악
ast-grep --pattern 'class Language {
  $$$
}'

Length of output: 47


@thezz9 네, 이해했습니다! Language 엔티티의 version 필드가 이미 "(17)" 형태로 괄호를 포함하고 있어서, getLanguageInfo() 메서드에서 getName() + getVersion()을 할 때 자연스럽게 "Java(17)" 형식이 되는 거네요.

제가 잘못 분석해서 불필요한 지적을 했습니다. 현재 구현과 스키마 예시가 일치하고 있군요. 감사합니다!


🏁 Script executed:

#!/bin/bash
# ripgrep으로 Language 클래스 찾기
rg -n "class Language" src/

# Language 엔티티의 version 필드 관련 코드 찾기
rg -n -A3 -B3 "version" src/ | grep -i language

# getVersion() 메서드 구현 찾기
rg -n -A5 "getVersion" src/

Length of output: 27438


@thezz9 확인해보니 흥미로운 점을 발견했습니다!

코드를 보면:

  • 테스트에서는 version = "17"로 평문으로 설정하고 있고
  • getLanguageInfo() 메서드는 language.getName() + language.getVersion()로 단순 연결하고 있습니다

하지만 사용자분이 말씀하신대로 실제 데이터베이스의 version 필드에 "(17)" 형태로 저장되어 있다면, 현재 구현이 올바르게 "Java(17)" 형식을 반환하게 되겠네요.

제가 테스트 코드만 보고 판단했는데, 실제 운영 데이터와 테스트 데이터의 형식이 다를 수 있다는 점을 놓쳤습니다. 감사합니다!


🏁 Script executed:

#!/bin/bash
# Language 엔티티의 전체 구조와 getVersion() 메서드 확인
cat src/main/java/org/ezcode/codetest/domain/language/model/entity/Language.java

# TestDataGenerator에서 실제로 저장되는 version 데이터 확인
rg -n -A10 -B5 "INSERT INTO language" src/test/java/org/ezcode/codetest/util/TestDataGenerator.java

Length of output: 1840


@thezz9 이제 완전히 이해했습니다!

코드를 보니:

  • Language 엔티티는 단순한 String version 필드에 Lombok @Getter를 사용
  • getLanguageInfo()getName() + getVersion()로 단순 연결
  • 테스트 데이터에서는 "v1", "v2" 형식으로 생성하지만
  • 실제 운영/개발 데이터에서는 version이 "(17)" 형태로 저장되어 있다

그래서 실제로는 "Java" + "(17)" = "Java(17)"이 되어 스키마 예시와 완벽하게 일치하는 거네요!

테스트 데이터와 실제 데이터의 형식이 다른 경우를 간과했습니다. 현재 구현이 올바르고 스키마 예시도 정확합니다. 제가 잘못 분석했네요, 죄송합니다! 🙏


🧬 Code Graph Analysis Results

Relevant snippet from src/main/java/org/ezcode/codetest/application/submission/dto/response/submission/SubmissionDetailResponse.java (lines 1-44)

This file defines a Java record SubmissionDetailResponse representing the response DTO for an individual submission result. It includes fields such as:

  • Long id: Submission ID
  • String language: Submission language (example: "Java(17)")
  • String sourceCode: Source code submitted
  • boolean isCorrect: Whether the submission is correct
  • String message: Result message (e.g., "Accepted")
  • Long executionTime: Execution time in seconds
  • Long memoryUsage: Memory usage in KB
  • LocalDateTime submittedAt: Submission timestamp (with nanoseconds truncated)

The record has a static factory method from(Submission submission) which creates an instance from a Submission entity by mapping its fields:

  • submission.getId()id
  • submission.getLanguageInfo()language
  • submission.getCode()sourceCode
  • submission.isCorrect()isCorrect
  • submission.getMessage()message
  • submission.getExecutionTime()executionTime
  • submission.getMemoryUsage()memoryUsage
  • submission.getCreatedAt().withNano(0)submittedAt (nanoseconds removed)

The language field example in the schema annotation is "Java(17)", which matches the user's comment about the version being included as (17).


Possibly relevant snippet from src/main/java/org/ezcode/codetest/domain/submission/model/entity/Submission.java (not provided)

The Submission entity class is referenced here, particularly the method getLanguageInfo(). This method likely returns the language string including the version (e.g., "Java(17)"). Understanding how getLanguageInfo() constructs this string would be relevant to the user's comment about the version format.


Summary of relevance:

  • The SubmissionDetailResponse record directly uses submission.getLanguageInfo() to populate the language field, which includes the version in parentheses (e.g., "Java(17)").
  • The user's comment about the version being "(17)" is reflected in the example and the code.
  • To fully understand or modify how the version appears, the implementation of Submission.getLanguageInfo() would be relevant but is not included here.

Irrelevant snippets:

  • The snippet from src/main/resources/static/js/test-mypage.js is unrelated to submission language or version formatting.
  • The snippet from GoogleOAuth2Response.java is unrelated to submission or language versioning.

[no_relevant_code_snippets beyond SubmissionDetailResponse.java]


✏️ Learnings added
Learnt from: thezz9
PR: ezcode-my/backend#175
File: src/main/java/org/ezcode/codetest/application/submission/dto/response/submission/SubmissionDetailResponse.java:15-16
Timestamp: 2025-07-26T12:06:47.998Z
Learning: Language 엔티티의 version 필드는 이미 괄호를 포함한 형식 (예: "(17)")으로 저장되어 있어서, getLanguageInfo() 메서드가 getName() + getVersion()을 반환할 때 "Java(17)" 형태가 된다.

Learnt from: thezz9
PR: ezcode-my/backend#175
File: src/main/java/org/ezcode/codetest/application/submission/dto/response/submission/SubmissionDetailResponse.java:15-16
Timestamp: 2025-07-26T12:06:47.998Z
Learning: Language 엔티티의 version 필드는 이미 괄호를 포함한 형식 (예: "(17)")으로 저장되어 있어서, getLanguageInfo() 메서드가 getName() + getVersion()을 반환할 때 "Java(17)" 형태가 된다.

Learnt from: thezz9
PR: ezcode-my/backend#175
File: src/main/java/org/ezcode/codetest/application/submission/dto/response/submission/SubmissionDetailResponse.java:15-16
Timestamp: 2025-07-26T12:06:47.998Z
Learning: Language 엔티티의 version 필드는 실제로는 괄호를 포함한 형식 (예: "(17)")으로 저장되어 있어서, getLanguageInfo() 메서드가 getName() + getVersion()을 반환할 때 "Java(17)" 형태가 된다. 테스트 데이터와 실제 운영 데이터의 형식이 다를 수 있다.

Learnt from: thezz9
PR: ezcode-my/backend#175
File: src/main/java/org/ezcode/codetest/application/submission/dto/response/submission/SubmissionDetailResponse.java:15-16
Timestamp: 2025-07-26T12:06:47.998Z
Learning: Language 엔티티의 version 필드는 실제 데이터에서는 괄호를 포함한 형식 (예: "(17)")으로 저장되어 있어서, getLanguageInfo() 메서드가 getName() + getVersion()을 반환할 때 "Java(17)" 형태가 된다. 테스트 데이터는 "v1", "v2" 형식을 사용하지만 실제 운영 데이터는 다른 형식을 사용한다.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.


🧠 Learnings used
Learnt from: thezz9
PR: ezcode-my/backend#36
File: src/main/java/org/ezcode/codetest/application/submission/dto/request/compile/CodeCompileRequest.java:5-9
Timestamp: 2025-06-06T07:52:58.941Z
Learning: CodeCompileRequest 레코드의 필드명(source_code, language_id)은 Java camelCase 컨벤션 대신 snake_case를 사용하는데, 이는 Judge0 API의 반환 값 형식에 맞추기 위한 의도적인 설계 결정이다.

Learnt from: thezz9
PR: ezcode-my/backend#30
File: src/main/java/org/ezcode/codetest/application/submission/service/SubmissionService.java:44-46
Timestamp: 2025-06-04T13:12:17.636Z
Learning: SubmissionService에서 "2 10" 입력값과 "12" 기대출력이 하드코딩되어 있는 것은 테스트 단계의 의도적인 구현이며, 추후 Problem 엔티티의 실제 테스트케이스로 대체 예정입니다.

Learnt from: thezz9
PR: ezcode-my/backend#36
File: src/main/java/org/ezcode/codetest/domain/problem/model/entity/ProblemLanguage.java:3-3
Timestamp: 2025-06-06T07:57:51.226Z
Learning: 사용자 thezz9는 Language 엔티티를 Submission 도메인으로 이동시킨 이유가 "제출하려면 필요해서"라고 설명했으며, Problem 도메인과 Submission 도메인 간의 종속성 위반 문제에 대한 해결 방안을 고민하고 있다.

Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:159-165
Timestamp: 2025-06-28T02:03:38.693Z
Learning: User thezz9's service (ezcode) targets Korean users exclusively ("찐 한국인밖에 안 옴"), so Korean language hardcoding in commit messages and UI elements is intentional and appropriate for their use case.

Learnt from: thezz9
PR: ezcode-my/backend#75
File: src/main/java/org/ezcode/codetest/application/submission/aop/CodeReviewLockAspect.java:25-41
Timestamp: 2025-06-19T06:37:57.845Z
Learning: User thezz9 tends to skip validation for scenarios they consider unlikely to occur, but is willing to implement defensive programming practices when suggested for code robustness.

Learnt from: thezz9
PR: ezcode-my/backend#114
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubApiClient.java:93-96
Timestamp: 2025-06-28T02:04:24.957Z
Learning: User thezz9 sometimes temporarily uses less secure or inconsistent exception handling (like RuntimeException with raw error bodies) for debugging purposes when error messages are being hidden in the normal application flow, but acknowledges this as technical debt and fixes it once debugging is complete.

Learnt from: thezz9
PR: ezcode-my/backend#132
File: src/main/java/org/ezcode/codetest/infrastructure/github/GitHubContentBuilder.java:72-72
Timestamp: 2025-07-02T09:39:31.485Z
Learning: User thezz9 prefers to proceed with breaking changes to path structures when it improves the organization, rather than maintaining backward compatibility or implementing migration strategies.

Learnt from: thezz9
PR: ezcode-my/backend#30
File: src/main/java/org/ezcode/codetest/domain/problem/model/dto/SubmissionData.java:42-53
Timestamp: 2025-06-04T13:12:16.729Z
Learning: 사용자 thezz9는 개발 시 기능적 정확성을 먼저 달성한 후 세부 리팩터링을 나중에 하는 접근 방식을 선호한다. 테스트 단계에서는 하드코딩된 값도 허용한다.


@Schema(description = "소스 코드", example = "System.out.println(\"Hello\");")
String sourceCode,

Expand All @@ -34,6 +37,7 @@ public record SubmissionDetailResponse(
public static SubmissionDetailResponse from(Submission submission) {
return new SubmissionDetailResponse(
submission.getId(),
submission.getLanguageInfo(),
submission.getCode(),
submission.isCorrect(),
submission.getMessage(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.FetchType;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
Expand All @@ -30,11 +31,11 @@ public class Submission extends BaseEntity {
@JoinColumn(name = "user_id", nullable = false)
private User user;

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "problem_id", nullable = false)
private Problem problem;

@ManyToOne
@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name = "language_id", nullable = false)
private Language language;

Expand Down Expand Up @@ -78,6 +79,10 @@ public Long getProblemId() {
return this.problem.getId();
}

public String getLanguageInfo() {
return language.getName() + language.getVersion();
}

public boolean isCorrect() {
return this.testCasePassedCount == this.testCaseTotalCount;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package org.ezcode.codetest.infrastructure.persistence.repository.submission.jpa;

import java.util.Collection;
import java.util.List;

import org.ezcode.codetest.domain.submission.model.entity.Submission;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface SubmissionJpaRepository extends JpaRepository<Submission, Long> {

@EntityGraph(attributePaths = {"problem", "language"})
List<Submission> findAllByUser_Id(Long userId);

@Query("""
Expand Down