Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix/#286] article 전체 카테고리 반영 SQL 수정 #287

Merged
merged 1 commit into from
Aug 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Comment on lines +87 to 89
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

전체 카테고리에 대해 where 조건이 발생되지 않도록 동적쿼리 수정

}
).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
Loading