-
Notifications
You must be signed in to change notification settings - Fork 1
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/#281] 아티클 조회수 순 정렬시 옵션 추가(article최신순) #282
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
확인 부탁드립니다
dslContext | ||
.select( | ||
ARTICLE_VIEW_COUNT.ARTICLE_ID, | ||
rowNumber().over(orderBy(ARTICLE_VIEW_COUNT.VIEW_COUNT.desc())).`as`("offset") | ||
) | ||
.from(ARTICLE_VIEW_COUNT) | ||
dslContext.select( | ||
ARTICLE_VIEW_COUNT.ARTICLE_ID, | ||
rowNumber().over( | ||
orderBy(ARTICLE_VIEW_COUNT.VIEW_COUNT.desc(), ARTICLE_VIEW_COUNT.ARTICLE_ID.desc()) | ||
).`as`("offset") | ||
).from(ARTICLE_VIEW_COUNT) | ||
.where(ARTICLE_VIEW_COUNT.DELETED_AT.isNull) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- as-is: VIEW_COUNT 로만 내림 차순 하여 10개 가져옴
- to-be: VIEW_COUNT가 같은 경우 ARTICLE_ID를 내림 차순하는 조건 추가(최신 글 우선)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CREATE TABLE ARTICLE_VIEW_COUNT
(
article_id BIGINT NOT NULL,
view_count BIGINT NOT NULL,
category_cd TINYINT NOT NULL,
deleted_at TIMESTAMP NULL DEFAULT NULL,
CONSTRAINT article_view_count_pk PRIMARY KEY (article_id)
);
위와 같이 article_id에 인덱싱이 되어 있어 인덱스 타고 갑니다
).where( | ||
when (query.category) { | ||
(null) -> noCondition() | ||
else -> field("article_view_count_offset_tb.category_cd").eq(query.category.code) | ||
} | ||
).limit(10) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
카테고리 옵션이 추가로 온 경우에 대해 동적 쿼리 적용했습니다
네 확인했슴다.! |
🎫 연관 이슈
resolved #281
💁♂️ PR 내용
🙏 작업
🙈 PR 참고 사항
📸 스크린샷
🤖 테스트 체크리스트