-
Notifications
You must be signed in to change notification settings - Fork 0
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
Conversation
if (!hasNext) { | ||
endIndex = schoolRepository.count().toInt() | ||
} | ||
val schools = schoolRepository.findAll().subList(startIndex, endIndex) |
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.
findall()보다는 page나 커서기반으로 조회하자
모든 데이터를 다 조회하면 성능이 매우 안좋을것같아
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.
page로 가져오면 다음 데이터가 있는지 hasNext 프로퍼티가 있어서 위에 hasNext 구하기 위한 쿼리는 없애자
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.
굿굿 이런 리뷰 조타
page 단위로 조회하는걸로 수정완
커서랑 페이징 중에 페이징이 메모리 적게 쓴다길래 페이징으로 해봤는데 별로면 말해줘~
.retrieve() | ||
.bodyToMono(String::class.java) | ||
.map { | ||
jacksonObjectMapper().readValue(it, ClassroomOpenApiResponse::class.java) |
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.
이 부분도 spring objectmapper 사용하자
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.
바꿨어~
val schools = schoolRepository.findAll(pageable) | ||
val hasNext = schools.hasNext() | ||
val classroomInfoList: MutableList<ClassroomInfoProvider.ClassroomInfo> = mutableListOf() | ||
schools.forEach { school -> |
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.
이 부분 forEach보다는 map을 사용해서 바로 List<ClassroomInfoProvider.ClassroomInfo>로 바꾸는거는 어때
val ORD_SC_NM: String?, | ||
val DDDEP_NM: String?, | ||
val CLASS_NM: String, | ||
val LOAD_DTM: String? |
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.
사용 안하는 필드는 제거하는거 어떄
@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> |
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.
기본으로 제공되는 메소드여서 override 안해도 될것같아
🗃 Issue
🔥 Task
📄 Reference