Skip to content

Commit

Permalink
fix: postgresql group by issue
Browse files Browse the repository at this point in the history
  • Loading branch information
alstn113 committed Dec 9, 2024
1 parent a2904fc commit 6c261b6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public class ExamSummaryDto {
private String description;
private ExamStatus status;
private AuthorDto author;
private Long questionCount;
private int questionCount;
private LocalDateTime createdAt;
private LocalDateTime updatedAt;

Expand All @@ -27,7 +27,7 @@ public ExamSummaryDto(
String description,
ExamStatus status,
AuthorDto author,
Long questionCount,
int questionCount,
LocalDateTime createdAt,
LocalDateTime updatedAt
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,14 @@ public List<ExamSummaryDto> findPublishedSummaries() {
exam.description.value,
exam.status,
AUTHOR_PROJECTION,
question.count(),
exam.questionGroup.questions.size(), // postgreSQL group by 문제
exam.createdAt,
exam.updatedAt
))
.from(exam)
.leftJoin(member).on(exam.memberId.eq(member.id))
.leftJoin(exam.questionGroup.questions, question)
.where(exam.status.eq(ExamStatus.PUBLISHED))
// TODO: 시험을 풀 수 있는 시간 내에만 조회되도록 수정
.groupBy(exam.id)
.orderBy(exam.updatedAt.desc())
.fetch();
}
Expand All @@ -60,15 +58,14 @@ public List<ExamSummaryDto> findMySummaries(ExamStatus status, Long memberId) {
exam.description.value,
exam.status,
AUTHOR_PROJECTION,
question.count(),
exam.questionGroup.questions.size(),
exam.createdAt,
exam.updatedAt
))
.from(exam)
.leftJoin(member).on(exam.memberId.eq(member.id))
.leftJoin(exam.questionGroup.questions, question)
.where(exam.memberId.eq(memberId), exam.status.eq(status))
.groupBy(exam.id)
.orderBy(exam.updatedAt.desc())
.fetch();
}
Expand Down

0 comments on commit 6c261b6

Please sign in to comment.