-
Notifications
You must be signed in to change notification settings - Fork 1
25학번 이전 교양분류 보여주는 기능 추가 #325
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
Merged
Merged
Changes from 8 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
ef4aa77
add oldCategory to Lecture
asp345 b799ab1
수강스누 배치에 구 교양분류 가져오는 부분 추가
asp345 c3e002e
구 교양분류 동기화 배치
asp345 3e8d4e0
2025년 이전 강의에는 저장 안함
asp345 cf8f27f
fix batch & remove AddOldCategoryJobConfig.kt
asp345 1462bf1
small fixes
asp345 ec374f7
add oldCategory to search
asp345 1c4e2c9
fix lint
asp345 f98b7a1
Merge remote-tracking branch 'origin/develop' into feature/old-category
asp345 0c30708
change name to categoryPre2025
asp345 e67b245
empty list as default value for categoryPre2025
asp345 fc00904
구 교양분류 수정/초기화 추가 및 초기화에 빠진 학년, 분류 값들 추가
asp345 357ba21
fix CustomTimetableLectureAddLegacyRequestDto
asp345 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package com.wafflestudio.snu4t.oldcategory.api | ||
|
|
||
| import org.springframework.context.annotation.Bean | ||
| import org.springframework.context.annotation.Configuration | ||
| import org.springframework.http.client.reactive.ReactorClientHttpConnector | ||
| import org.springframework.web.reactive.function.client.ExchangeStrategies | ||
| import org.springframework.web.reactive.function.client.WebClient | ||
| import reactor.netty.http.client.HttpClient | ||
|
|
||
| @Configuration | ||
| class GoogleDocsApiConfig { | ||
| companion object { | ||
| const val GOOGLE_DOCS_BASE_URL = "https://docs.google.com" | ||
| } | ||
|
|
||
| @Bean | ||
| fun googleDocsApi(): GoogleDocsApi { | ||
| val exchangeStrategies: ExchangeStrategies = | ||
| ExchangeStrategies.builder() | ||
| .codecs { it.defaultCodecs().maxInMemorySize(-1) } // to unlimited memory size | ||
| .build() | ||
|
|
||
| val httpClient = | ||
| HttpClient.create() | ||
| .followRedirect(true) | ||
| .compress(true) | ||
|
|
||
| return WebClient.builder() | ||
| .baseUrl(GOOGLE_DOCS_BASE_URL) | ||
| .clientConnector(ReactorClientHttpConnector(httpClient)) | ||
| .exchangeStrategies(exchangeStrategies) | ||
| .build() | ||
| .let(::GoogleDocsApi) | ||
| } | ||
| } | ||
|
|
||
| class GoogleDocsApi(webClient: WebClient) : WebClient by webClient |
36 changes: 36 additions & 0 deletions
36
batch/src/main/kotlin/oldcategory/repository/OldCategoryRepository.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| package com.wafflestudio.snu4t.oldcategory.repository | ||
|
|
||
| import com.wafflestudio.snu4t.oldcategory.api.GoogleDocsApi | ||
| import org.springframework.core.io.buffer.PooledDataBuffer | ||
| import org.springframework.http.MediaType | ||
| import org.springframework.stereotype.Component | ||
| import org.springframework.web.reactive.function.client.awaitBody | ||
| import org.springframework.web.reactive.function.client.awaitExchange | ||
| import org.springframework.web.reactive.function.client.createExceptionAndAwait | ||
|
|
||
| @Component | ||
| class OldCategoryRepository( | ||
| private val googleDocsApi: GoogleDocsApi, | ||
| ) { | ||
| companion object { | ||
| const val SPREADSHEET_PATH = "/spreadsheets/d" | ||
| const val SPREADSHEET_KEY = "/1Ok2gu7rW1VYlKmC_zSjNmcljef0kstm19P9zJ_5s_QA" | ||
| } | ||
|
|
||
| suspend fun fetchOldCategories(): PooledDataBuffer = | ||
| googleDocsApi.get().uri { builder -> | ||
| builder.run { | ||
| path(SPREADSHEET_PATH) | ||
| path(SPREADSHEET_KEY) | ||
| path("/export") | ||
| queryParam("format", "xlsx") | ||
| build() | ||
| } | ||
| }.accept(MediaType.TEXT_HTML).awaitExchange { | ||
| if (it.statusCode().is2xxSuccessful) { | ||
| it.awaitBody() | ||
| } else { | ||
| throw it.createExceptionAndAwait() | ||
| } | ||
| } | ||
| } |
37 changes: 37 additions & 0 deletions
37
batch/src/main/kotlin/oldcategory/service/OldCategoryFetchService.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| package com.wafflestudio.snu4t.oldcategory.service | ||
|
|
||
| import com.wafflestudio.snu4t.oldcategory.repository.OldCategoryRepository | ||
| import org.apache.poi.ss.usermodel.WorkbookFactory | ||
| import org.springframework.stereotype.Service | ||
|
|
||
| @Service | ||
| class OldCategoryFetchService( | ||
| private val oldCategoryRepository: OldCategoryRepository, | ||
| ) { | ||
| suspend fun getOldCategories(): Map<String, String> { | ||
| val oldCategoriesXlsx = oldCategoryRepository.fetchOldCategories() | ||
| val workbook = WorkbookFactory.create(oldCategoriesXlsx.asInputStream()) | ||
| return workbook.sheetIterator().asSequence() | ||
| .flatMap { sheet -> | ||
| sheet.rowIterator().asSequence() | ||
| .drop(3) | ||
| .filter { row -> | ||
| row.getCell(7).stringCellValue.isNotBlank() && row.getCell(1).stringCellValue.isNotBlank() | ||
| } | ||
| .map { row -> | ||
| try { | ||
| val currentCourseNumber = row.getCell(7).stringCellValue | ||
| val oldCategory = row.getCell(1).stringCellValue | ||
| if (currentCourseNumber.isBlank() || oldCategory.isBlank()) { | ||
| return@map null | ||
| } | ||
| currentCourseNumber to oldCategory | ||
| } catch (e: Exception) { | ||
| null | ||
| } | ||
| } | ||
| .filterNotNull() | ||
| } | ||
| .toMap() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this 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.
위에 isNotBlank로 필터링하는 로직이 있어서 로직이 중복되는 것 같아요.
아래 filter 부분은 없어도 될 것 같아요