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

[Feat/#241] 메인 워크북 API 구현 - 회원 워크북 API #262

Merged
merged 8 commits into from
Aug 1, 2024

Conversation

belljun3395
Copy link
Collaborator

🎫 연관 이슈

resolved: #241

💁‍♂️ PR 내용

  • 메인 워크북 API 구현 - 회원 워크북 API

🙏 작업

  • selectAllWorkbookSubscriptionStatus 쿼리 구현: 멤버의 구독 기록이 있는 워크북을 조회합니다.
  • countAllWorkbookSubscription 쿼리 구현: 워크북의 구독자를 조회합니다.

🙈 PR 참고 사항

📸 스크린샷

스크린샷 2024-07-29 오후 12 10 42

🤖 테스트 체크리스트

  • 체크 미완료
  • 체크 완료

@belljun3395 belljun3395 requested a review from hun-ca as a code owner July 29, 2024 03:23
@github-actions github-actions bot added the feature 새로운 기능을 만들 때 사용됩니다 label Jul 29, 2024
@belljun3395 belljun3395 changed the title Feat/#241 belljun3395 [Feat/#241] 메인 워크북 API 구현 - 회원 워크북 API Jul 29, 2024
Comment on lines +77 to +91
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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

스크린샷 2024-07-29 오후 12 10 19

여기서도 TARGET_WORKBOOK_ID에 인덱스가 없어서 All이네요..

https://github.com/YAPP-Github/24th-Web-Team-1-BE/pull/261/files#r1694450225

Copy link
Member

Choose a reason for hiding this comment

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

네 target member id만 갖는 인덱스 생성 필요할거 같습니다. 기존 유니크 제약조건 그냥 없애죠

Comment on lines +134 to +140
fun countAllWorkbookSubscriptionQuery() = dslContext.select(
SUBSCRIPTION.TARGET_WORKBOOK_ID,
DSL.count(SUBSCRIPTION.TARGET_WORKBOOK_ID)
)
.from(SUBSCRIPTION)
.groupBy(SUBSCRIPTION.TARGET_WORKBOOK_ID)
.query
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

스크린샷 2024-07-29 오후 12 11 14

요건 인덱스 잘 탑니다.

Copy link
Member

Choose a reason for hiding this comment

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

저 컬럼이 인덱스 첫번째 컬럼으로 지정되어서 인덱스 탔네요

Copy link
Collaborator Author

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)

네 그런데 그냥 인덱스는 아니고 다중인덱스 설정이라 커버링 인덱스 탔습니다.

Copy link
Member

Choose a reason for hiding this comment

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

넵 인덱스 수정 필여하겠어요 이따 회의때 논의 ㄱ

Comment on lines +31 to +39
/**
* 임시 코드
* Batch 코드에서 currentDay가 totalDay보다 큰 경우가 발생하여
* currentDay가 totalDay보다 크면 totalDay로 변경
* */
var currentDay = it.currentDay
if (it.currentDay > it.totalDay) {
currentDay = it.totalDay
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

요기는 배치에서 구독 완료한 것도 진행을 올리고 있어서 수정하고 제거하겠습니다.

Copy link
Member

@hun-ca hun-ca left a comment

Choose a reason for hiding this comment

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

articleInfo는 그냥 string으로 가져오나요?

@belljun3395
Copy link
Collaborator Author

belljun3395 commented Jul 30, 2024

articleInfo는 그냥 string으로 가져오나요?

네 우선은 해당 값이 빈 "{}"이어서 string으로 가지고 오고 추후에도 objectmapper.writevalueAsString으로 가져올 것 같습니다.

@belljun3395 belljun3395 requested a review from hun-ca August 1, 2024 15:18
Copy link
Member

@hun-ca hun-ca left a comment

Choose a reason for hiding this comment

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

고생하셨습니다~ 😁

Comment on lines +57 to +68
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]
)
)
)
Copy link
Member

Choose a reason for hiding this comment

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

articleId 추가 확인했습니다!

@belljun3395 belljun3395 merged commit 75ffe72 into main Aug 1, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature 새로운 기능을 만들 때 사용됩니다
Projects
None yet
Development

Successfully merging this pull request may close these issues.

메인 워크북 API 구현 - 회원 워크북 API
2 participants