diff --git a/app/templating/DateHelper.scala b/app/templating/DateHelper.scala index 046e43a054fa8..60f2fa70ae6fd 100644 --- a/app/templating/DateHelper.scala +++ b/app/templating/DateHelper.scala @@ -12,7 +12,7 @@ import chess.format.pgn.Tag.Date trait DateHelper { self: I18nHelper with StringHelper with NumberHelper => - export PeriodLocales.{ showPeriod, showDuration } + export PeriodLocales.showDuration private val dateTimeStyle = "MS" private val dateStyle = "M-" diff --git a/app/views/relay/roundForm.scala b/app/views/relay/roundForm.scala index 2a210ee6c0d24..12dc0d5860cc4 100644 --- a/app/views/relay/roundForm.scala +++ b/app/views/relay/roundForm.scala @@ -100,9 +100,11 @@ object roundForm: )(form3.flatpickr(_, minDate = None)), isGranted(_.Relay) option form3.group( - form("throttle"), - raw("Throttle in seconds"), - help = raw("Optional, to manually throttle requests. Min 2s, max 60s.").some, + form("period"), + raw("Period in seconds"), + help = raw( + "Optional, how long to wait between requests. Min 2s, max 60s. Defaults to automatic based on the number of viewers." + ).some, half = true )(form3.input(_, typ = "number")) ), diff --git a/modules/i18n/src/main/PeriodLocales.scala b/modules/i18n/src/main/PeriodLocales.scala index 4043db7a06bfa..34961f2e1bcff 100644 --- a/modules/i18n/src/main/PeriodLocales.scala +++ b/modules/i18n/src/main/PeriodLocales.scala @@ -3,7 +3,7 @@ package lila.i18n import org.joda.time.format.{ PeriodFormat, PeriodFormatter } import org.joda.time.{ DurationFieldType, PeriodType, Period as JodaPeriod } import play.api.i18n.Lang -import java.time.{ Duration, Period } +import java.time.Duration // TODO replace with threeten-extra? // https://www.threeten.org/threeten-extra/apidocs/org.threeten.extra/org/threeten/extra/AmountFormats.html @@ -18,8 +18,5 @@ object PeriodLocales: private def periodFormatter(using lang: Lang): PeriodFormatter = PeriodFormat wordBased lang.locale - def showPeriod(period: Period)(using Lang): String = - periodFormatter print JodaPeriod(period).normalizedStandard(periodType) - def showDuration(duration: Duration)(using Lang): String = periodFormatter print JodaPeriod(duration.toMillis).normalizedStandard(periodType) diff --git a/modules/relay/src/main/RelayFetch.scala b/modules/relay/src/main/RelayFetch.scala index 4bcb610ca6806..e1f2eec33e0ba 100644 --- a/modules/relay/src/main/RelayFetch.scala +++ b/modules/relay/src/main/RelayFetch.scala @@ -144,7 +144,7 @@ final private class RelayFetch( gameProxy.upgradeIfPresent flatMap gameRepo.withInitialFens flatMap { games => if (games.size == ids.size) - games.map { case (game, fen) => + games.map { (game, fen) => pgnDump(game, fen, gameIdsUpstreamPgnFlags).dmap(_.render) }.parallel dmap MultiPgn.apply else diff --git a/modules/swiss/src/main/SwissApi.scala b/modules/swiss/src/main/SwissApi.scala index d43e2e7268b63..a64ed7dc1e56e 100644 --- a/modules/swiss/src/main/SwissApi.scala +++ b/modules/swiss/src/main/SwissApi.scala @@ -4,6 +4,7 @@ import akka.stream.scaladsl.* import alleycats.Zero import java.nio.charset.StandardCharsets.UTF_8 import java.security.MessageDigest +import java.time.format.{ DateTimeFormatter, FormatStyle } import reactivemongo.akkastream.cursorProducer import reactivemongo.api.* import reactivemongo.api.bson.* @@ -145,24 +146,20 @@ final class SwissApi( def scheduleNextRound(swiss: Swiss, date: Instant): Funit = Sequencing(swiss.id)(cache.swissCache.notFinishedById) { old => - (!old.settings.manualRounds).?? { - mongo.swiss + for + _ <- !old.settings.manualRounds ?? mongo.swiss .updateField($id(old.id), "settings.i", Swiss.RoundInterval.manual) .void - } >> { - if (old.isCreated) mongo.swiss.updateField($id(old.id), "startsAt", date).void - else if (old.isStarted && old.nbOngoing == 0) + _ <- old.isCreated ?? mongo.swiss.updateField($id(old.id), "startsAt", date).void + _ <- (!old.isFinished && old.nbOngoing == 0) ?? mongo.swiss.updateField($id(old.id), "nextRoundAt", date).void >>- { - import java.time.format.{ DateTimeFormatter, FormatStyle } val formatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT) val showDate = formatter print date systemChat(swiss.id, s"Round ${swiss.round.value + 1} scheduled at $showDate UTC") } - else funit - } >>- { + yield cache.swissCache clear swiss.id socket.reload(swiss.id) - } } def verdicts(swiss: Swiss, me: Option[User]): Fu[SwissCondition.All.WithVerdicts] = diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 21ab001735199..0ad4d2708a1f6 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -57,7 +57,7 @@ object Dependencies { } object reactivemongo { - val driver = "org.reactivemongo" %% "reactivemongo" % "1.1.0-RC7" + val driver = "org.reactivemongo" %% "reactivemongo" % "1.1.0-RC9" val stream = "org.reactivemongo" %% "reactivemongo-akkastream" % "1.1.0-RC9" val shaded = "org.reactivemongo" % "reactivemongo-shaded-native" % s"1.1.0-RC6-$os-x86-64" // val kamon = "org.reactivemongo" %% "reactivemongo-kamon" % "1.0.8"