mirror of
https://github.com/slhaf/Partner.git
synced 2026-05-12 08:43:02 +08:00
refactor(ActionScheduler): correct actions loading logic in hour/day updating
This commit is contained in:
@@ -235,12 +235,13 @@ class ActionScheduler : AgentRunningSubModule<Set<ScheduledActionData>, Void>()
|
|||||||
|
|
||||||
suspend fun checkThenExecute(then: (currentTime: ZonedDateTime) -> Unit) = wheelActionsLock.withLock {
|
suspend fun checkThenExecute(then: (currentTime: ZonedDateTime) -> Unit) = wheelActionsLock.withLock {
|
||||||
fun loadActions(
|
fun loadActions(
|
||||||
|
source: Set<ScheduledActionData>,
|
||||||
now: ZonedDateTime,
|
now: ZonedDateTime,
|
||||||
load: (latestExecutingTime: ZonedDateTime, actionData: ScheduledActionData) -> Unit,
|
load: (latestExecutingTime: ZonedDateTime, actionData: ScheduledActionData) -> Unit,
|
||||||
repair: () -> Unit
|
repair: () -> Unit
|
||||||
) {
|
) {
|
||||||
val runLoading = {
|
val runLoading = {
|
||||||
for (actionData in listScheduledActions()) {
|
for (actionData in source) {
|
||||||
val latestExecutingTime =
|
val latestExecutingTime =
|
||||||
parseToZonedDateTime(
|
parseToZonedDateTime(
|
||||||
actionData.scheduleType,
|
actionData.scheduleType,
|
||||||
@@ -271,7 +272,7 @@ class ActionScheduler : AgentRunningSubModule<Set<ScheduledActionData>, Void>()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadActions(currentTime, load, repair)
|
loadActions(actionsGroupByHour[currentTime.hour], currentTime, load, repair)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun loadDayActions(currentTime: ZonedDateTime) {
|
fun loadDayActions(currentTime: ZonedDateTime) {
|
||||||
@@ -285,7 +286,7 @@ class ActionScheduler : AgentRunningSubModule<Set<ScheduledActionData>, Void>()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadActions(currentTime, load, repair)
|
loadActions(listScheduledActions(), currentTime, load, repair)
|
||||||
}
|
}
|
||||||
|
|
||||||
val currentTime = ZonedDateTime.now()
|
val currentTime = ZonedDateTime.now()
|
||||||
|
|||||||
Reference in New Issue
Block a user