feat: added cacheUpdateJobs

Signed-off-by: moonleay <contact@moonleay.net>
This commit is contained in:
moonleay 2023-10-05 11:39:23 +02:00
parent 886d891787
commit 1c17a5d2be
Signed by: moonleay
GPG key ID: 82667543CCD715FB
3 changed files with 145 additions and 0 deletions

View file

@ -0,0 +1,50 @@
/*
* lilJudd
* Copyright (C) 2023 moonleay
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.jobs
import dev.inmo.krontab.KronScheduler
import kotlinx.coroutines.Job
import net.moonleay.lilJudd.data.api.Splatoon3ApiCache
import net.moonleay.lilJudd.data.api.type.ApiDataType
import net.moonleay.lilJudd.data.api.type.ApiRequestType
import net.moonleay.lilJudd.jobs.component.CronjobType
import net.moonleay.lilJudd.jobs.component.ICronjob
import net.moonleay.lilJudd.util.Logger
object Splatoon3ApiFestivalAndCoopUpdateScheduler : ICronjob {
override val jobName: String
get() = "Splatoon3ApiFestivalAndCoopUpdateScheduler"
override val jobIncoming: String
get() = "0 0 0 /1 *" // once a day
override val jobType: CronjobType
get() = CronjobType.INFINITE
override val continueJob: Boolean
get() = true
override lateinit var cronjobJob: Job
override lateinit var scheduler: KronScheduler
override suspend fun jobFunction() {
Logger.out("Running Splatoon3ApiFestivalUpdateScheduler.")
Splatoon3ApiCache.updateData(ApiDataType.SPLATFESTS, ApiRequestType.AUTOMATIC_CACHE_UPDATE)
Logger.out("Splatoon3ApiFestivalUpdateScheduler finished.")
Logger.out("Running Splatoon3ApiCoopUpdateScheduler.")
Splatoon3ApiCache.updateData(ApiDataType.COOP, ApiRequestType.AUTOMATIC_CACHE_UPDATE)
Logger.out("Splatoon3ApiCoopUpdateScheduler finished.")
}
}

View file

@ -0,0 +1,48 @@
/*
* lilJudd
* Copyright (C) 2023 moonleay
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.jobs
import dev.inmo.krontab.KronScheduler
import kotlinx.coroutines.Job
import net.moonleay.lilJudd.data.api.Splatoon3ApiCache
import net.moonleay.lilJudd.data.api.type.ApiDataType
import net.moonleay.lilJudd.data.api.type.ApiRequestType
import net.moonleay.lilJudd.jobs.component.CronjobType
import net.moonleay.lilJudd.jobs.component.ICronjob
import net.moonleay.lilJudd.util.Logger
object Splatoon3ApiScheduleUpdateScheduler : ICronjob {
override val jobName: String
get() = "Splatoon3ApiScheduleUpdateScheduler"
override val jobIncoming: String
get() = "0 /30 * * *" //Every 30 minutes
override val jobType: CronjobType
get() = CronjobType.INFINITE
override val continueJob: Boolean
get() = true
override lateinit var cronjobJob: Job
override lateinit var scheduler: KronScheduler
override suspend fun jobFunction() {
Logger.out("Running Splatoon3ApiScheduleUpdateScheduler.")
Splatoon3ApiCache.updateData(ApiDataType.SCHEDULES, ApiRequestType.AUTOMATIC_CACHE_UPDATE)
StatusUpdater.refreshStatusList(System.currentTimeMillis())
Logger.out("Splatoon3ApiScheduleUpdateScheduler finished.")
}
}

View file

@ -0,0 +1,47 @@
/*
* lilJudd
* Copyright (C) 2023 moonleay
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.moonleay.lilJudd.jobs
import dev.inmo.krontab.KronScheduler
import kotlinx.coroutines.Job
import net.moonleay.lilJudd.data.api.Splatoon3ApiCache
import net.moonleay.lilJudd.data.api.type.ApiDataType
import net.moonleay.lilJudd.data.api.type.ApiRequestType
import net.moonleay.lilJudd.jobs.component.CronjobType
import net.moonleay.lilJudd.jobs.component.ICronjob
import net.moonleay.lilJudd.util.Logger
object Splatoon3ApiSplatnetGearUpdateScheduler : ICronjob {
override val jobName: String
get() = "Splatoon3ApiSplatnetGearUpdateScheduler"
override val jobIncoming: String
get() = "* * /6 * *" //Every 6 hours
override val jobType: CronjobType
get() = CronjobType.INFINITE
override val continueJob: Boolean
get() = true
override lateinit var cronjobJob: Job
override lateinit var scheduler: KronScheduler
override suspend fun jobFunction() {
Logger.out("Running Splatoon3ApiSplatnetGearUpdateScheduler.")
Splatoon3ApiCache.updateData(ApiDataType.SPLATNETGEAR, ApiRequestType.AUTOMATIC_CACHE_UPDATE)
Logger.out("Splatoon3ApiSplatnetGearUpdateScheduler finished.")
}
}