From 641b2e0822c4242746d8cb631da1496bad36cc47 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9A=B0=ED=98=81=EC=A4=80=20=28HyukJoon=20Woo=29?= Date: Sun, 7 Apr 2024 12:12:07 +0900 Subject: [PATCH] Fix: give 0.0 to score when keyword is null or empty on notice. (#254) --- .../csereal/core/notice/database/NoticeRepository.kt | 4 +++- .../wafflestudio/csereal/core/notice/dto/NoticeSearchDto.kt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/notice/database/NoticeRepository.kt b/src/main/kotlin/com/wafflestudio/csereal/core/notice/database/NoticeRepository.kt index f2615c8f..0277a82f 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/notice/database/NoticeRepository.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/notice/database/NoticeRepository.kt @@ -2,6 +2,7 @@ package com.wafflestudio.csereal.core.notice.database import com.querydsl.core.BooleanBuilder import com.querydsl.core.types.Projections +import com.querydsl.core.types.dsl.Expressions import com.querydsl.jpa.impl.JPAQueryFactory import com.wafflestudio.csereal.common.enums.ContentSearchSortType import com.wafflestudio.csereal.common.repository.CommonRepository @@ -142,7 +143,8 @@ class NoticeRepositoryImpl( noticeEntity.isPinned, noticeEntity.attachments.isNotEmpty, noticeEntity.isPrivate, - scoreOrNull + // if scoreOrNull is null, put 0.0 + scoreOrNull ?: Expressions.numberTemplate(Double::class.javaObjectType, "0.0") ) ).from(noticeEntity) .leftJoin(noticeTagEntity).on(noticeTagEntity.notice.eq(noticeEntity)) diff --git a/src/main/kotlin/com/wafflestudio/csereal/core/notice/dto/NoticeSearchDto.kt b/src/main/kotlin/com/wafflestudio/csereal/core/notice/dto/NoticeSearchDto.kt index 3e8d0409..8dffde59 100644 --- a/src/main/kotlin/com/wafflestudio/csereal/core/notice/dto/NoticeSearchDto.kt +++ b/src/main/kotlin/com/wafflestudio/csereal/core/notice/dto/NoticeSearchDto.kt @@ -19,7 +19,7 @@ data class NoticeSearchDto( isPinned: Boolean, hasAttachment: Boolean, isPrivate: Boolean, - score: Double? + score: Double ) : this(id, title, createdAt, isPinned, hasAttachment, isPrivate) constructor(entity: NoticeEntity, hasAttachment: Boolean) : this(