Skip to content

Commit

Permalink
earlier start for delayed broadcast rounds
Browse files Browse the repository at this point in the history
  • Loading branch information
ornicar committed Jun 18, 2024
1 parent 8cbc395 commit 156e1e1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions modules/relay/src/main/RelayApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -392,17 +392,21 @@ final class RelayApi(
.list[RelayRound](
$doc(
"startsAt"
.$lt(nowInstant.plusMinutes(30)) // start 30 minutes early to fetch boards
.$gt(nowInstant.minusDays(1)), // bit late now
// start early to fetch boards
.$lt(nowInstant.plusSeconds(RelayDelay.maxSeconds.value))
.$gt(nowInstant.minusDays(1)), // bit late now
"startedAt".$exists(false),
"sync.until".$exists(false)
)
)
.flatMap:
_.sequentiallyVoid { relay =>
logger.info(s"Automatically start $relay")
requestPlay(relay.id, v = true)
}
_.sequentiallyVoid: relay =>
val earlyMinutes = Math.min(60, 30 + relay.sync.delay.so(_.value / 60))
relay.startsAt
.exists(_.isBefore(nowInstant.plusMinutes(earlyMinutes)))
.so:
logger.info(s"Automatically start $relay")
requestPlay(relay.id, v = true)

private[relay] def autoFinishNotSyncing: Funit =
roundRepo.coll
Expand All @@ -417,10 +421,9 @@ final class RelayApi(
)
)
.flatMap:
_.sequentiallyVoid { relay =>
_.sequentiallyVoid: relay =>
logger.info(s"Automatically finish $relay")
update(relay)(_.finish)
}

private[relay] def WithRelay[A: Zero](id: RelayRoundId)(f: RelayRound => Fu[A]): Fu[A] =
byId(id).flatMapz(f)
Expand Down

0 comments on commit 156e1e1

Please sign in to comment.