본문 바로가기

Project18

크롤링에 batch update(bulk insert)와 coroutine으로 속도 올리기 [Kotlin + spring boot] 시간표 업데이트 시 8분이나 걸려 실시간 남은 좌석 수 확인에 대한 메리트가 없다고 판단했다. 데이터를 insert 하는데 2분, 시간표 데이터를 가져오는데 6분 30초 대략 9분 정도가 걸려 간혹 10분이 지나 업데이트 도중 다시 스케줄러가 실행되는 에러가 생겼다. 예전에 파이썬에서 사용했던 pool.map이 생각나 멀티쓰레딩이나 멀티프로세싱으로 크롤링을 진행하고 insert 삽입 시간을 줄이기 위한 방법을 찾아보았다. 목차 기존 코드 및 수행 시간 @Async @Scheduled(cron = "0 0/1 * * * ?") fun chkMovieShowingTime() { var time = lastUpdateTimeRepositorySupport.getLastTime(code) if (time == .. 2023. 5. 25.
ShowTime 데이터 저장 시간 줄이기 showTimeRepository.truncateShowTime() val showTimeMovieInfo = movieInfoRepositorySupport.getShowTimeMovieInfo() val movieInfoMap = chgListTOMap(showTimeMovieInfo) val allstartTime = LocalDateTime.now() val mbTheaters = theaterDataRepositorySupport.getTheaterData("MB") val lcTheaters = theaterDataRepositorySupport.getTheaterData("LC") val cgvTheaters = theaterDataRepositorySupport.getTheaterData(.. 2023. 3. 14.
JpaRepository join using QueryProjection with DTO(kotlin) JpaRepository의 join을 사용하는 방법은 여러가지가 있습니다. 그 중 저는 QueryProjection을 이용한 방법을 사용했습니다. 코틀린 data class에서 QueryProjection을 사용하기 위해서는 아래와 같이 선언해주시면 됩니다. data class MovieListDTO @QueryProjection constructor( val MovieId: String = "", ... ) MovieInfoController @RestController @RequestMapping("/api/movieinfo") class MovieInfoController( val movieInfoService: MovieInfoServiceimpl, val movieCreatorService: M.. 2023. 3. 13.
JpaRepository saveAll(Insert) 사용하기 TheaterData(movieTheater=MB, city= 인, brchKR=검단, brchEN=Geomdan, addrKR= 인천광역시 서구 서곶로 788 (당하동) 홀리랜드 4층 메가박스 검단, addrEN=788, Seogot-ro, Seo-gu, Incheon, Republic of Korea, theaterCode=4041) TheaterData를 구하던 중 city가 제대로 안들어가 확인해 보니 주소에 띄어쓰기가 들어가 있는 친구가 있습니다. 주소들은 전부 trim을 적용해 줬습니다. addrEN의 경우 메가박스만 존재합니다. 나머지 영화관은 영어 주소를 제공하지 않습니다. CGV의 경우 CINE de CHEF 가 붙은 동일한 영화관이 존재합니다. 압구정의 경우 CINE de CHEF 압구.. 2023. 3. 12.