Skip to content

Commit

Permalink
Merge branch 'master' into consistent_multiboard
Browse files Browse the repository at this point in the history
* master:
  upgrade reactivemongo
  fix manually setting date of swiss first round
  remove unused showPeriod (lichess-org#12670)
  fix relay sync.period
  • Loading branch information
ornicar committed Apr 24, 2023
2 parents 0c947ab + 75b747a commit 62af208
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 19 deletions.
2 changes: 1 addition & 1 deletion app/templating/DateHelper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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-"
Expand Down
8 changes: 5 additions & 3 deletions app/views/relay/roundForm.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
),
Expand Down
5 changes: 1 addition & 4 deletions modules/i18n/src/main/PeriodLocales.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
2 changes: 1 addition & 1 deletion modules/relay/src/main/RelayFetch.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 6 additions & 9 deletions modules/swiss/src/main/SwissApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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] =
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 62af208

Please sign in to comment.