-
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
[Feat/#241] 메인 워크북 API 구현 - 회원 워크북 API #262
Conversation
fun selectAllWorkbookSubscriptionStatusQuery(query: SelectAllMemberWorkbookSubscriptionStatusNotConsiderDeletedAtQuery) = | ||
dslContext.select( | ||
SUBSCRIPTION.TARGET_WORKBOOK_ID.`as`(MemberWorkbookSubscriptionStatusRecord::workbookId.name), | ||
SUBSCRIPTION.DELETED_AT.isNull.`as`(MemberWorkbookSubscriptionStatusRecord::isActiveSub.name), | ||
DSL.max(SUBSCRIPTION.PROGRESS).add(1).`as`(MemberWorkbookSubscriptionStatusRecord::currentDay.name), | ||
DSL.max(MAPPING_WORKBOOK_ARTICLE.DAY_COL).`as`(MemberWorkbookSubscriptionStatusRecord::totalDay.name) | ||
) | ||
.from(SUBSCRIPTION) | ||
.leftJoin(MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE) | ||
.on(SUBSCRIPTION.TARGET_WORKBOOK_ID.eq(MappingWorkbookArticle.MAPPING_WORKBOOK_ARTICLE.WORKBOOK_ID)) | ||
.where(SUBSCRIPTION.MEMBER_ID.eq(query.memberId)) | ||
.and(SUBSCRIPTION.TARGET_MEMBER_ID.isNull) | ||
.groupBy(SUBSCRIPTION.TARGET_WORKBOOK_ID, SUBSCRIPTION.DELETED_AT) | ||
.query | ||
|
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.
여기서도 TARGET_WORKBOOK_ID에 인덱스가 없어서 All이네요..
https://github.com/YAPP-Github/24th-Web-Team-1-BE/pull/261/files#r1694450225
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.
네 target member id만 갖는 인덱스 생성 필요할거 같습니다. 기존 유니크 제약조건 그냥 없애죠
fun countAllWorkbookSubscriptionQuery() = dslContext.select( | ||
SUBSCRIPTION.TARGET_WORKBOOK_ID, | ||
DSL.count(SUBSCRIPTION.TARGET_WORKBOOK_ID) | ||
) | ||
.from(SUBSCRIPTION) | ||
.groupBy(SUBSCRIPTION.TARGET_WORKBOOK_ID) | ||
.query |
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.
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.
저 컬럼이 인덱스 첫번째 컬럼으로 지정되어서 인덱스 탔네요
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.
-> Table scan on (actual time=0.242..0.264 rows=8 loops=1)
-> Aggregate using temporary table (actual time=0.236..0.236 rows=8 loops=1)
-> Covering index scan on SUBSCRIPTION using subscription_unique_member_id_target_workbook_id (cost=7.25 rows=70) (actual time=0.0338..0.11 rows=70 loops=1)
네 그런데 그냥 인덱스는 아니고 다중인덱스 설정이라 커버링 인덱스 탔습니다.
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.
넵 인덱스 수정 필여하겠어요 이따 회의때 논의 ㄱ
/** | ||
* 임시 코드 | ||
* Batch 코드에서 currentDay가 totalDay보다 큰 경우가 발생하여 | ||
* currentDay가 totalDay보다 크면 totalDay로 변경 | ||
* */ | ||
var currentDay = it.currentDay | ||
if (it.currentDay > it.totalDay) { | ||
currentDay = it.totalDay | ||
} |
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.
요기는 배치에서 구독 완료한 것도 진행을 올리고 있어서 수정하고 제거하겠습니다.
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.
articleInfo는 그냥 string으로 가져오나요?
네 우선은 해당 값이 빈 "{}"이어서 string으로 가지고 오고 추후에도 objectmapper.writevalueAsString으로 가져올 것 같습니다. |
# Conflicts: # api-repo/src/main/kotlin/com/few/api/repo/dao/article/ArticleDao.kt
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.
고생하셨습니다~ 😁
SubscribeWorkbookDetail( | ||
workbookId = it.workbookId, | ||
isActiveSub = WorkBookStatus.fromStatus(it.isActiveSub), | ||
currentDay = currentDay, | ||
totalDay = it.totalDay, | ||
totalSubscriber = workbookSubscriptionCountRecords[it.workbookId]?.toLong() ?: 0, | ||
articleInfo = objectMapper.writeValueAsString( | ||
mapOf( | ||
"articleId" to workbookSubscriptionCurrentArticleIdRecords[it.workbookId] | ||
) | ||
) | ||
) |
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.
articleId 추가 확인했습니다!
🎫 연관 이슈
resolved: #241
💁♂️ PR 내용
🙏 작업
🙈 PR 참고 사항
📸 스크린샷
🤖 테스트 체크리스트