Fixed algorithm error with calculating canUpdate due to wrapping around the day at midnight
This commit is contained in:
parent
4003dd81d4
commit
2d3b7b0817
@ -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,10 +44,11 @@ class UpdateUserQueueService(
|
||||
.limit(1)
|
||||
.fetchOneInto(OffsetDateTime::class.java)
|
||||
|
||||
var canUpdate = !isProcessing
|
||||
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)
|
||||
canUpdate = false
|
||||
|
||||
Loading…
Reference in New Issue
Block a user