diff --git a/nise-backend/src/main/kotlin/com/nisemoe/nise/service/UpdateUserQueueService.kt b/nise-backend/src/main/kotlin/com/nisemoe/nise/service/UpdateUserQueueService.kt index 95164c7..3fdd28e 100644 --- a/nise-backend/src/main/kotlin/com/nisemoe/nise/service/UpdateUserQueueService.kt +++ b/nise-backend/src/main/kotlin/com/nisemoe/nise/service/UpdateUserQueueService.kt @@ -8,6 +8,7 @@ import org.jooq.DSLContext import org.springframework.http.ResponseEntity import org.springframework.messaging.simp.SimpMessagingTemplate import org.springframework.stereotype.Service +import java.time.Duration import java.time.OffsetDateTime import java.time.ZoneOffset @@ -43,12 +44,13 @@ class UpdateUserQueueService( .limit(1) .fetchOneInto(OffsetDateTime::class.java) - var canUpdate = !isProcessing - if(lastCompletedUpdateQueue != null) { + var canUpdate = !isProcessing; + if (lastCompletedUpdateQueue != null) { val now = OffsetDateTime.now(ZoneOffset.UTC) - val hoursSinceLastUpdate = now.hour - lastCompletedUpdateQueue.hour + val duration = Duration.between(lastCompletedUpdateQueue, now) + val hoursSinceLastUpdate = duration.toHours() - if(hoursSinceLastUpdate < USER_UPDATE_INTERVAL_HOURS) + if (hoursSinceLastUpdate < USER_UPDATE_INTERVAL_HOURS) canUpdate = false }