Skip to content

Commit

Permalink
update : 기존 운영/발행예정 QSet 쿼리 조회 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
xonmin committed Aug 9, 2024
1 parent 2835d1c commit fb568a1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions entity/src/main/kotlin/com/mashup/dojo/QuestionSetRepository.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ import java.time.LocalDateTime

interface QuestionSetRepository : JpaRepository<QuestionSetEntity, String> {
// publishedYn : True && publishedAt > now -> 현재 운영중인 QuestionSet
fun findFirstByPublishedYnTrueAndPublishedAtAfterOrderByPublishedAt(compareTime: LocalDateTime = LocalDateTime.now()): QuestionSetEntity?
fun findByPublishedAtAfterAndEndAtBefore(
publishedCompareTime: LocalDateTime = LocalDateTime.now(),
endTimeCompareTime: LocalDateTime = LocalDateTime.now(),
): QuestionSetEntity?

// publishedYn : True && publishedAt < now -> 발행 직전(예정) QuestionSet
fun findFirstByPublishedYnTrueAndPublishedAtBeforeOrderByPublishedAt(compareTime: LocalDateTime = LocalDateTime.now()): QuestionSetEntity?
fun findByStatusAndPublishedAtAfter(
status: Status,
compareTime: LocalDateTime = LocalDateTime.now(),
): QuestionSetEntity?

fun findTopByOrderByPublishedAtDesc(): QuestionSetEntity?
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class DefaultQuestionService(

// 현재 운영중인 QuestionSet
override fun getOperatingQuestionSet(): QuestionSet? {
return questionSetRepository.findFirstByPublishedYnTrueAndPublishedAtAfterOrderByPublishedAt()
return questionSetRepository.findByPublishedAtAfterAndEndAtBefore(LocalDateTime.now(), LocalDateTime.now())
?.toQuestionSet() ?: run {
log.error { "Published And Operating QuestionSet Entity not found" }
null
Expand All @@ -119,7 +119,7 @@ class DefaultQuestionService(

// 발행 출격 준비 완료 QuestionSet
override fun getNextOperatingQuestionSet(): QuestionSet? {
return questionSetRepository.findFirstByPublishedYnTrueAndPublishedAtBeforeOrderByPublishedAt()
return questionSetRepository.findByStatusAndPublishedAtAfter(Status.UPCOMING, LocalDateTime.now())
?.toQuestionSet() ?: run {
log.error { "Published And Prepared for sortie QuestionSet Entity not found" }
null
Expand Down

0 comments on commit fb568a1

Please sign in to comment.