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

학급 open api batch로 가져오기 #40

Merged
merged 6 commits into from
May 7, 2024

Conversation

sominyun
Copy link
Member

@sominyun sominyun commented May 6, 2024

🗃 Issue

🔥 Task

  • 학교 100개씩 학급을 가져와서 batch로 처리하도록 리팩토링
  • mongodb 일단 주석 처리하고 menu 클래스를 entity로 바꿈
  • 달려있는 주석들 지워야 하면 수정

📄 Reference

  • None

@sominyun sominyun added the 🔨 Refactor 리팩터링 label May 6, 2024
@sominyun sominyun requested a review from tlarbals824 May 6, 2024 20:53
if (!hasNext) {
endIndex = schoolRepository.count().toInt()
}
val schools = schoolRepository.findAll().subList(startIndex, endIndex)
Copy link
Contributor

Choose a reason for hiding this comment

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

findall()보다는 page나 커서기반으로 조회하자
모든 데이터를 다 조회하면 성능이 매우 안좋을것같아

Copy link
Contributor

Choose a reason for hiding this comment

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

page로 가져오면 다음 데이터가 있는지 hasNext 프로퍼티가 있어서 위에 hasNext 구하기 위한 쿼리는 없애자

Copy link
Member Author

@sominyun sominyun May 7, 2024

Choose a reason for hiding this comment

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

굿굿 이런 리뷰 조타
page 단위로 조회하는걸로 수정완
커서랑 페이징 중에 페이징이 메모리 적게 쓴다길래 페이징으로 해봤는데 별로면 말해줘~

.retrieve()
.bodyToMono(String::class.java)
.map {
jacksonObjectMapper().readValue(it, ClassroomOpenApiResponse::class.java)
Copy link
Contributor

Choose a reason for hiding this comment

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

이 부분도 spring objectmapper 사용하자

Copy link
Member Author

Choose a reason for hiding this comment

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

바꿨어~

val schools = schoolRepository.findAll(pageable)
val hasNext = schools.hasNext()
val classroomInfoList: MutableList<ClassroomInfoProvider.ClassroomInfo> = mutableListOf()
schools.forEach { school ->
Copy link
Contributor

Choose a reason for hiding this comment

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

이 부분 forEach보다는 map을 사용해서 바로 List<ClassroomInfoProvider.ClassroomInfo>로 바꾸는거는 어때

val ORD_SC_NM: String?,
val DDDEP_NM: String?,
val CLASS_NM: String,
val LOAD_DTM: String?
Copy link
Contributor

Choose a reason for hiding this comment

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

사용 안하는 필드는 제거하는거 어떄

@Query("SELECT s.schoolCode FROM School s WHERE s.schoolCode IN :schoolCodes")
fun findSchoolCodeBySchoolCodeIn(schoolCodes: List<String>): List<String>

override fun findAll(pageable: Pageable): Page<School>
Copy link
Contributor

Choose a reason for hiding this comment

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

기본으로 제공되는 메소드여서 override 안해도 될것같아

@sominyun sominyun merged commit 5b19248 into develop May 7, 2024
1 check passed
@sominyun sominyun deleted the feature/#39-classroom-open-api branch May 7, 2024 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔨 Refactor 리팩터링
Projects
None yet
Development

Successfully merging this pull request may close these issues.

청크 단위 학급 조회 리팩터링
2 participants