Skip to content

Commit c26c48a

Browse files
committed
Increase default static message cronjob frequency
1 parent d50adcd commit c26c48a

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

client/src/main/kotlin/org/dreamexposure/discal/client/business/cronjob/StaticMessageUpdateCronJob.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ class StaticMessageUpdateCronJob(
2323
private val staticMessageService: StaticMessageService,
2424
private val metricService: MetricService,
2525
):ApplicationRunner {
26+
private final val intervalMinutes = Config.TIMING_STATIC_MESSAGE_UPDATE_TASK_RUN_INTERVAL_MINUTES.getLong().asMinutes()
27+
2628
override fun run(args: ApplicationArguments) {
27-
Flux.interval(Config.TIMING_STATIC_MESSAGE_UPDATE_TASK_RUN_INTERVAL_MINUTES.getLong().asMinutes())
29+
Flux.interval(intervalMinutes)
2830
.onBackpressureDrop()
2931
.flatMap { doUpdate() }
3032
.onErrorResume { Mono.empty() }
@@ -38,11 +40,11 @@ class StaticMessageUpdateCronJob(
3840
try {
3941
val messages = staticMessageService.getEnabledStaticMessagesForShard(getShardIndex(), getShardCount())
4042
//We have no interest in updating the message so close to its last update
41-
.filter { Duration.between(Instant.now(), it.lastUpdate).abs().toMinutes() >= 30 }
43+
.filter { Duration.between(Instant.now(), it.lastUpdate).abs() >= intervalMinutes.minusMinutes(1) }
4244
// Only update messages in range
4345
.filter {
44-
Duration.between(Instant.now(), it.scheduledUpdate).toMinutes() <= 60
45-
|| (it.forcedUpdate != null && Duration.between(Instant.now(), it.forcedUpdate).toMinutes() <= 60)
46+
Duration.between(Instant.now(), it.scheduledUpdate) <= intervalMinutes
47+
|| (it.forcedUpdate != null && Duration.between(Instant.now(), it.forcedUpdate) <= intervalMinutes)
4648
}
4749

4850
LOGGER.debug("StaticMessageUpdateCronJob | Found ${messages.size} messages to update for shard ${getShardIndex()}")

core/src/main/kotlin/org/dreamexposure/discal/core/config/Config.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ enum class Config(private val key: String, private var value: Any? = null) {
3939
TIMING_BOT_STATUS_UPDATE_MINUTES("bot.timing.status-update.minutes", 5),
4040
TIMING_ANNOUNCEMENT_TASK_RUN_INTERVAL_MINUTES("bot.timing.announcement.task-run-interval.minutes", 5),
4141
TIMING_WIZARD_TIMEOUT_MINUTES("bot.timing.wizard-timeout.minutes", 30),
42-
TIMING_STATIC_MESSAGE_UPDATE_TASK_RUN_INTERVAL_MINUTES("bot.timing.static-message.update.task-run-interval.minutes", 30),
42+
TIMING_STATIC_MESSAGE_UPDATE_TASK_RUN_INTERVAL_MINUTES("bot.timing.static-message.update.task-run-interval.minutes", 15),
4343

4444
// Bot secrets
4545
SECRET_DISCAL_API_KEY("bot.secret.api-token"),

0 commit comments

Comments
 (0)