Skip to content

Commit

Permalink
Merge branch 'master' into holding-down-move-buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
johndoknjas committed Dec 11, 2024
2 parents 4c194bb + 5ef7cf2 commit 399d15f
Show file tree
Hide file tree
Showing 32 changed files with 1,096 additions and 326 deletions.
8 changes: 0 additions & 8 deletions modules/api/src/main/GameApiV2.scala
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ final class GameApiV2(

import GameApiV2.*

private val keepAliveInterval = 70.seconds // play's idleTimeout = 75s

def exportOne(game: Game, config: OneConfig)(using Translate): Fu[String] =
game.pgnImport.ifTrue(config.imported) match
case Some(imported) => fuccess(imported.pgn.value)
Expand Down Expand Up @@ -149,7 +147,6 @@ final class GameApiV2(
.throttle(config.perSecond.value, 1 second)
.via(upgradeOngoingGame)
.via(preparationFlow(config, realPlayers))
.keepAlive(keepAliveInterval, () => emptyMsgFor(config))

def exportByIds(config: ByIdsConfig)(using Translate): Source[String, ?] =
Source.futureSource:
Expand Down Expand Up @@ -264,11 +261,6 @@ final class GameApiV2(
case Format.PGN => pgnDump.formatter(config.flags)
case Format.JSON => jsonFormatter(config)

private def emptyMsgFor(config: Config) =
config.format match
case Format.PGN => "\n"
case Format.JSON => "{}\n"

private def jsonFormatter(config: Config)(using Translate) =
(
game: Game,
Expand Down
3 changes: 1 addition & 2 deletions modules/api/src/main/PgnDump.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,5 +56,4 @@ final class PgnDump(
analysis: Option[Analysis],
teams: Option[GameTeams],
realPlayers: Option[RealPlayers]
) =>
apply(game, initialFen, analysis, flags, teams, realPlayers).dmap(annotator.toPgnString).dmap(_.value)
) => apply(game, initialFen, analysis, flags, teams, realPlayers).map(annotator.toPgnString).dmap(_.value)
39 changes: 0 additions & 39 deletions modules/common/src/main/Debouncer.scala

This file was deleted.

2 changes: 1 addition & 1 deletion modules/coreI18n/src/main/key.scala
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@ object I18nKey:
val `timezone`: I18nKey = "broadcast:timezone"
val `fideRatingCategory`: I18nKey = "broadcast:fideRatingCategory"
val `optionalDetails`: I18nKey = "broadcast:optionalDetails"
val `upcomingBroadcasts`: I18nKey = "broadcast:upcomingBroadcasts"
val `pastBroadcasts`: I18nKey = "broadcast:pastBroadcasts"
val `allBroadcastsByMonth`: I18nKey = "broadcast:allBroadcastsByMonth"
val `nbBroadcasts`: I18nKey = "broadcast:nbBroadcasts"
Expand Down Expand Up @@ -1134,6 +1133,7 @@ object I18nKey:
val `notifyWeb`: I18nKey = "preferences:notifyWeb"
val `notifyDevice`: I18nKey = "preferences:notifyDevice"
val `bellNotificationSound`: I18nKey = "preferences:bellNotificationSound"
val `blindfold`: I18nKey = "preferences:blindfold"

object puzzle:
val `puzzles`: I18nKey = "puzzle:puzzles"
Expand Down
5 changes: 1 addition & 4 deletions modules/relay/src/main/RelayListing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,7 @@ final class RelayListing(
as = "rounds",
local = "_id",
foreign = "tourId",
pipe = List(
$doc("$match" -> $doc("finishedAt".$exists(false))),
$doc("$sort" -> RelayRoundRepo.sort.asc)
)
pipe = List($doc("$sort" -> RelayRoundRepo.sort.asc))
)

private def readTourRound(doc: Bdoc): Option[RelayTour.WithRounds] = for
Expand Down
6 changes: 3 additions & 3 deletions modules/relay/src/main/RelayPlayer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package lila.relay
import scala.collection.immutable.SeqMap
import play.api.libs.json.*
import scalalib.Json.writeAs
import scalalib.Debouncer
import chess.{ ByColor, Color, FideId, Outcome, PlayerName, IntRating }
import chess.rating.{ Elo, IntRatingDiff }

Expand All @@ -12,7 +13,6 @@ import lila.study.StudyPlayer.json.given
import lila.memo.CacheApi
import lila.core.fide.{ Player as FidePlayer }
import lila.common.Json.given
import lila.common.Debouncer
import lila.core.fide.FideTC

// Player in a tournament with current performance rating and list of games
Expand Down Expand Up @@ -86,7 +86,7 @@ private final class RelayPlayerApi(
chapterPreviewApi: ChapterPreviewApi,
cacheApi: CacheApi,
fidePlayerGet: lila.core.fide.GetPlayer
)(using Executor, Scheduler):
)(using Executor)(using scheduler: Scheduler):
import RelayPlayer.*

type RelayPlayers = SeqMap[StudyPlayer.Id, RelayPlayer]
Expand Down Expand Up @@ -115,7 +115,7 @@ private final class RelayPlayerApi(

def invalidate(id: RelayTourId) = invalidateDebouncer.push(id)

private val invalidateDebouncer = Debouncer[RelayTourId](3 seconds, 32): id =>
private val invalidateDebouncer = Debouncer[RelayTourId](scheduler.scheduleOnce(3.seconds, _), 32): id =>
import lila.memo.CacheApi.invalidate
cache.invalidate(id)
jsonCache.invalidate(id)
Expand Down
15 changes: 9 additions & 6 deletions modules/simul/src/main/SimulApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import chess.{ ByColor, Status }
import monocle.syntax.all.*
import play.api.libs.json.Json
import scalalib.paginator.Paginator
import scalalib.Debouncer

import lila.common.Json.given
import lila.common.{ Bus, Debouncer }
import lila.common.Bus
import lila.core.perf.UserWithPerfs
import lila.core.socket.SendToFlag
import lila.core.team.LightTeam
Expand All @@ -29,7 +30,7 @@ final class SimulApi(
repo: SimulRepo,
verify: SimulCondition.Verify,
cacheApi: lila.memo.CacheApi
)(using Executor, Scheduler)
)(using Executor)(using scheduler: Scheduler)
extends lila.core.simul.SimulApi:

private val workQueue = scalalib.actor.AsyncActorSequencers[SimulId](
Expand Down Expand Up @@ -67,7 +68,7 @@ final class SimulApi(
_ <- repo.create(simul)
yield
publish()
lila.common.Bus.pub(Propagate(SimulCreate(me.userId, simul.id, simul.fullName)).toFollowersOf(me.userId))
Bus.pub(Propagate(SimulCreate(me.userId, simul.id, simul.fullName)).toFollowersOf(me.userId))
simul

def update(prev: Simul, setup: SimulForm.Setup, teams: Seq[LightTeam])(using me: Me): Fu[Simul] =
Expand Down Expand Up @@ -118,7 +119,7 @@ final class SimulApi(
val newSimul = simul.addApplicant(SimulApplicant(player, accepted = false))
for _ <- repo.update(newSimul)
yield
lila.common.Bus.pub:
Bus.pub:
Propagate(SimulJoin(me.userId, simul.id, simul.fullName)).toFollowersOf(user.id)
socket.reload(newSimul.id)
publish()
Expand Down Expand Up @@ -314,5 +315,7 @@ final class SimulApi(

private object publish:
private val siteMessage = SendToFlag("simul", Json.obj("t" -> "reload"))
private val debouncer = Debouncer[Unit](5 seconds, 1)(_ => Bus.publish(siteMessage, "sendToFlag"))
def apply() = debouncer.push(())
private val debouncer =
Debouncer[Unit](scheduler.scheduleOnce(5.seconds, _), 1): _ =>
Bus.publish(siteMessage, "sendToFlag")
def apply() = debouncer.push(())
13 changes: 9 additions & 4 deletions modules/tournament/src/main/TournamentApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ import akka.stream.scaladsl.*
import com.roundeights.hasher.Algo
import play.api.libs.json.*
import scalalib.paginator.Paginator
import scalalib.Debouncer
import chess.IntRating

import lila.common.{ Bus, Debouncer }
import lila.common.Bus
import lila.core.game.LightPov
import lila.core.round.{ AbortForce, GoBerserk }
import lila.core.team.LightTeam
Expand Down Expand Up @@ -39,8 +40,12 @@ final class TournamentApi(
waitingUsers: WaitingUsersApi,
cacheApi: lila.memo.CacheApi,
lightUserApi: lila.core.user.LightUserApi
)(using Executor, akka.actor.ActorSystem, Scheduler, akka.stream.Materializer, lila.core.i18n.Translator)
extends lila.core.tournament.TournamentApi:
)(using scheduler: Scheduler)(using
Executor,
akka.actor.ActorSystem,
akka.stream.Materializer,
lila.core.i18n.Translator
) extends lila.core.tournament.TournamentApi:

export tournamentRepo.{ byId as get }

Expand Down Expand Up @@ -710,7 +715,7 @@ final class TournamentApi(
}

private object publish:
private val debouncer = Debouncer[Unit](15 seconds, 1): _ =>
private val debouncer = Debouncer[Unit](scheduler.scheduleOnce(15.seconds, _), 1): _ =>
given play.api.i18n.Lang = lila.core.i18n.defaultLang
fetchUpdateTournaments.flatMap(apiJsonView.apply).foreach { json =>
Bus.publish(
Expand Down
2 changes: 1 addition & 1 deletion project/Dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object Dependencies {
}

object scalalib {
val version = "11.3.2"
val version = "11.4.1"
val core = "org.lichess" %% "scalalib-core" % version
val model = "org.lichess" %% "scalalib-model" % version
val playJson = "org.lichess" %% "scalalib-play-json" % version
Expand Down
Loading

0 comments on commit 399d15f

Please sign in to comment.