File tree Expand file tree Collapse file tree
common/src/main/kotlin/com/team1/hangsha/event/service
src/main/resources/db/migration Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -43,9 +43,10 @@ class EventSyncService(
4343
4444 val orgName = e.majorTypes.getOrNull(0 )?.trim()?.takeIf { it.isNotBlank() }
4545 val orgId = orgName?.let { getOrCreateCategoryId(orgGroupId, it) }
46- val typeName = normalizeProgramType(e.majorTypes.getOrNull( 1 ) )
46+ val typeName = normalizeProgramType(e)
4747
48- val statusId = e.status?.let { findCategoryId(statusGroupId, it) }
48+ val statusName = normalizeStatus(e.status)
49+ val statusId = statusName?.let { findCategoryId(statusGroupId, it) }
4950 val eventTypeId = typeName?.let { findCategoryId(typeGroupId, it) }
5051
5152 val applyStart = e.applyStart?.let { dateStart(it) }
@@ -207,9 +208,29 @@ class EventSyncService(
207208 }
208209 }
209210
210- private fun normalizeProgramType (raw : String? ): String? {
211+ private fun normalizeStatus (raw : String? ): String? {
211212 val s = raw?.trim()
212213 if (s.isNullOrBlank()) return null
214+ return when (s) {
215+ " 마감임박" -> " 모집중"
216+ else -> s
217+ }
218+ }
219+
220+ private fun normalizeProgramType (e : CrawledProgramEvent ): String? {
221+ val candidates = buildList {
222+ addAll(e.majorTypes)
223+ e.title?.let { add(it) }
224+ addAll(e.tags)
225+ }
226+
227+ if (candidates.any { it.contains(" openlnl" , ignoreCase = true ) }) {
228+ return " OpenLnL"
229+ }
230+
231+ val s = e.majorTypes.getOrNull(1 )?.trim()
232+ if (s.isNullOrBlank()) return null
233+
213234 return when (s) {
214235 " 레크리에이션" -> " 기타"
215236 else -> s
Original file line number Diff line number Diff line change 1+ -- 프로그램 유형: OpenLnL 카테고리 추가
2+ INSERT INTO categories (group_id, name, sort_order)
3+ SELECT cg .id , ' OpenLnL' , 6
4+ FROM category_groups cg
5+ WHERE cg .name = ' 프로그램 유형'
6+ AND NOT EXISTS (
7+ SELECT 1
8+ FROM categories c
9+ WHERE c .group_id = cg .id
10+ AND c .name = ' OpenLnL'
11+ );
12+
13+ -- 모집현황: 마감임박 -> 모집중 통합
14+ UPDATE events e
15+ JOIN categories imminent ON imminent .id = e .status_id
16+ JOIN category_groups cg ON cg .id = imminent .group_id
17+ JOIN categories recruiting ON recruiting .group_id = imminent .group_id AND recruiting .name = ' 모집중'
18+ SET e .status_id = recruiting .id
19+ WHERE cg .name = ' 모집현황'
20+ AND imminent .name = ' 마감임박' ;
You can’t perform that action at this time.
0 commit comments