Skip to content

Commit

Permalink
[Fix/#286] article 전체 카테고리 반영 SQL 수정 (#287)
Browse files Browse the repository at this point in the history
fix: article 전체 카테고리 반영 SQL 수정
  • Loading branch information
hun-ca authored Aug 3, 2024
1 parent 9b111d9 commit 373fa96
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.few.api.repo.dao.article.query.ArticleViewCountQuery
import com.few.api.repo.dao.article.query.SelectArticlesOrderByViewsQuery
import com.few.api.repo.dao.article.query.SelectRankByViewsQuery
import com.few.api.repo.dao.article.record.SelectArticleViewsRecord
import com.few.data.common.code.CategoryType
import jooq.jooq_dsl.tables.ArticleViewCount.ARTICLE_VIEW_COUNT
import org.jooq.DSLContext
import org.jooq.impl.DSL.*
Expand Down Expand Up @@ -76,15 +77,15 @@ class ArticleViewCountDao(
field("article_view_count_offset_tb.article_id").`as`(SelectArticleViewsRecord::articleId.name),
field("article_view_count_offset_tb.view_count").`as`(SelectArticleViewsRecord::views.name)
).from(
select()
dslContext.select()
.from(ARTICLE_VIEW_COUNT)
.where(ARTICLE_VIEW_COUNT.DELETED_AT.isNull)
.orderBy(ARTICLE_VIEW_COUNT.VIEW_COUNT.desc(), ARTICLE_VIEW_COUNT.ARTICLE_ID.desc())
.limit(query.offset, Long.MAX_VALUE)
.asTable("article_view_count_offset_tb")
).where(
when (query.category) {
(null) -> noCondition()
when {
(query.category == CategoryType.All) -> noCondition()
else -> field("article_view_count_offset_tb.category_cd").eq(query.category.code)
}
).limit(11)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import com.few.data.common.code.CategoryType

data class SelectArticlesOrderByViewsQuery(
val offset: Long,
val category: CategoryType?,
val category: CategoryType,
)
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class ReadArticlesUseCase(
val articleViewsRecords: MutableList<SelectArticleViewsRecord> = articleViewCountDao.selectArticlesOrderByViews(
SelectArticlesOrderByViewsQuery(
offset,
CategoryType.fromCode(useCaseIn.categoryCd)
CategoryType.fromCode(useCaseIn.categoryCd) ?: CategoryType.All
)
).toMutableList()

Expand Down

0 comments on commit 373fa96

Please sign in to comment.