From 97a48be30eb234f4f5acf4e17e369d8ab4491fef Mon Sep 17 00:00:00 2001 From: Ethan Date: Fri, 21 Jun 2024 21:32:56 +0900 Subject: [PATCH] =?UTF-8?q?fix:=20=EC=A4=91=EB=B3=B5=EB=90=9C=20scheduler?= =?UTF-8?q?=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schedule/service/SchedulerService.kt | 78 ------------------- 1 file changed, 78 deletions(-) delete mode 100644 src/main/kotlin/backend/itracker/schedule/service/SchedulerService.kt diff --git a/src/main/kotlin/backend/itracker/schedule/service/SchedulerService.kt b/src/main/kotlin/backend/itracker/schedule/service/SchedulerService.kt deleted file mode 100644 index c229579..0000000 --- a/src/main/kotlin/backend/itracker/schedule/service/SchedulerService.kt +++ /dev/null @@ -1,78 +0,0 @@ -package backend.itracker.schedule.service - -import backend.itracker.crawl.airpods.service.AirPodsService -import backend.itracker.crawl.ipad.service.IpadService -import backend.itracker.crawl.mac.service.MacService -import backend.itracker.crawl.macbook.service.MacbookService -import backend.itracker.crawl.service.CrawlService -import backend.itracker.crawl.watch.service.AppleWatchService -import io.github.oshai.kotlinlogging.KotlinLogging -import org.springframework.scheduling.annotation.Scheduled -import org.springframework.stereotype.Component -import kotlin.time.measureTime - -private const val CRAWLING_TIME = "0 0 3 * * *" -private const val TIME_ZONE = "Asia/Seoul" - -private val logger = KotlinLogging.logger {} - -@Component -class SchedulerService( - private val crawlService: CrawlService, - private val macbookService: MacbookService, - private val ipadService: IpadService, - private val appleWatchService: AppleWatchService, - private val macService: MacService, - private val airPodsService: AirPodsService -) { - - @Scheduled(cron = CRAWLING_TIME, zone = TIME_ZONE) - fun crawlMacbook() { - logger.info { "맥북 크롤링 시작. " } - val times = measureTime { - val macbooks = crawlService.crawlMacbook() - macbookService.saveAll(macbooks) - } - logger.info { "맥북 크롤링 끝. 시간: $times" } - } - - @Scheduled(cron = CRAWLING_TIME, zone = TIME_ZONE) - fun crawlIpad() { - logger.info { "아이패드 크롤링 시작. " } - val times = measureTime { - val ipads = crawlService.crawlIpad() - ipadService.saveAll(ipads) - } - logger.info { "아이패드 크롤링 끝. 시간: $times" } - } - - @Scheduled(cron = CRAWLING_TIME, zone = TIME_ZONE) - fun crawlAppleWatch() { - logger.info { "애플워치 크롤링 시작. " } - val times = measureTime { - val appleWatches = crawlService.crawlAppleWatch() - appleWatchService.saveAll(appleWatches) - } - logger.info { "애플워치 크롤링 끝. 시간: $times" } - } - - @Scheduled(cron = CRAWLING_TIME, zone = TIME_ZONE) - fun crawlMac() { - logger.info { "맥 크롤링 시작. " } - val times = measureTime { - val macs = crawlService.crawlMac() - macService.saveAll(macs) - } - logger.info { "맥 크롤링 끝. 시간: $times" } - } - - @Scheduled(cron = CRAWLING_TIME, zone = TIME_ZONE) - fun crawlAirPods() { - logger.info { "에어팟 크롤링 시작. " } - val times = measureTime { - val airPods = crawlService.crawlAirPods() - airPodsService.saveAll(airPods) - } - logger.info { "에어팟 크롤링 끝. 시간: $times" } - } -}