@@ -65,7 +65,7 @@ class VacancyNotifierServiceImpl(
6565 log.info(" 시작: ${registrationPhase.name} " )
6666 val pageCount =
6767 runCatching {
68- getPageCount()
68+ getPageCount(coursebook )
6969 }.getOrElse {
7070 log.error(" 에러가 발생했거나 부하 기간입니다. {}" , it.message, it)
7171 delay(30L .seconds)
@@ -77,7 +77,7 @@ class VacancyNotifierServiceImpl(
7777
7878 // 수강 사이트 부하를 분산하기 위해 강의 전체를 20등분해서 각각 요청
7979 (1 .. pageCount).chunked(pageCount / 20 ).forEach { chunkedPages ->
80- val registrationStatus = getRegistrationStatus(chunkedPages)
80+ val registrationStatus = getRegistrationStatus(chunkedPages, coursebook )
8181 if (registrationStatus.all { it.registrationCount == 0 }) return VacancyNotificationJobResult .REGISTRATION_IS_NOT_STARTED
8282
8383 val registrationStatusMap =
@@ -157,19 +157,22 @@ class VacancyNotifierServiceImpl(
157157 this .quota == this .registrationCount
158158 }
159159
160- private suspend fun getPageCount (): Int {
161- val firstPageContent = getSugangSnuSearchContent(1 )
160+ private suspend fun getPageCount (coursebook : Coursebook ): Int {
161+ val firstPageContent = getSugangSnuSearchContent(1 , coursebook )
162162 val totalCount =
163163 firstPageContent.select(" div.content > div.search-result-con > small > em" ).text().toInt()
164164 return (totalCount + 9 ) / COUNT_PER_PAGE
165165 }
166166
167- private suspend fun getRegistrationStatus (pages : List <Int >): List <RegistrationStatus > =
167+ private suspend fun getRegistrationStatus (
168+ pages : List <Int >,
169+ coursebook : Coursebook ,
170+ ): List <RegistrationStatus > =
168171 supervisorScope {
169172 pages
170173 .map { page ->
171174 async {
172- getSugangSnuSearchContent(page).extractRegistrationStatus()
175+ getSugangSnuSearchContent(page, coursebook ).extractRegistrationStatus()
173176 }
174177 }.awaitAll()
175178 .flatten()
@@ -211,8 +214,16 @@ class VacancyNotifierServiceImpl(
211214 }
212215 }
213216
214- private suspend fun getSugangSnuSearchContent (pageNo : Int ): Element {
215- val webPageDataBuffer = sugangSnuRepository.getSearchPageHtml(pageNo)
217+ private suspend fun getSugangSnuSearchContent (
218+ pageNo : Int ,
219+ coursebook : Coursebook ,
220+ ): Element {
221+ val webPageDataBuffer =
222+ sugangSnuRepository.getSearchPageHtml(
223+ year = coursebook.year,
224+ semester = coursebook.semester,
225+ pageNo = pageNo,
226+ )
216227 return try {
217228 Jsoup
218229 .parse(webPageDataBuffer.asInputStream(), Charsets .UTF_8 .name(), " " )
0 commit comments