Skip to content

Commit

Permalink
학기강좌검색 평점 버그 fix (#101)
Browse files Browse the repository at this point in the history
* 학기강좌검색 평점 버그 fix

* 추가 버그수정 (isHidden 제외)
  • Loading branch information
Hank-Choi authored Apr 4, 2024
1 parent 168bbd6 commit 217ab90
Showing 1 changed file with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class LectureRepositoryImpl(private val queryFactory: JPAQueryFactory) : Lecture
.leftJoin(lecture.semesterLectures, semesterLecture)
.leftJoin(semesterLecture.evaluations, lectureEvaluation)
.groupBy(lecture)
.where(*predicates)
.where(*predicates, lectureEvaluation.isHidden.eq(false))
.offset(pageable.offset).limit(pageable.pageSize.toLong()).fetch()

val total = queryFactory.select(
Expand All @@ -76,30 +76,34 @@ class LectureRepositoryImpl(private val queryFactory: JPAQueryFactory) : Lecture
extractCriteriaFromQuery(request.query),
)

val queryResult =
queryFactory.select(
val lectureSubQuery = queryFactory.selectFrom(lecture)
.innerJoin(lecture.semesterLectures, semesterLecture)
.where(*predicates)
.offset(pageable.offset).limit(pageable.pageSize.toLong()).fetch()

val queryResult = queryFactory.select(
Projections.constructor(
LectureDto::class.java,
lecture.id,
lecture.title,
lecture.instructor,
lecture.department,
lecture.courseNumber,
lecture.credit,
lecture.academicYear,
lecture.category,
lecture.classification,
Projections.constructor(
LectureDto::class.java,
lecture.id,
lecture.title,
lecture.instructor,
lecture.department,
lecture.courseNumber,
lecture.credit,
lecture.academicYear,
lecture.category,
lecture.classification,
Projections.constructor(
LectureEvaluationSimpleSummary::class.java,
lectureEvaluation.rating.avg(),
),
LectureEvaluationSimpleSummary::class.java,
lectureEvaluation.rating.avg(),
),
).from(semesterLecture)
.innerJoin(semesterLecture.lecture, lecture)
.leftJoin(semesterLecture.evaluations, lectureEvaluation)
.groupBy(lecture)
.where(*predicates)
.offset(pageable.offset).limit(pageable.pageSize.toLong()).fetch()
),
).from(lecture)
.innerJoin(lecture.semesterLectures, semesterLecture)
.leftJoin(semesterLecture.evaluations, lectureEvaluation)
.where(lecture.id.`in`(lectureSubQuery.map { it.id }), lectureEvaluation.isHidden.eq(false))
.groupBy(lecture)
.fetch()

val total = queryFactory.select(
semesterLecture.count(),
Expand Down

0 comments on commit 217ab90

Please sign in to comment.