use round proxy in TV
parent
89e63a38f7
commit
17a445d42c
|
@ -191,7 +191,7 @@ lazy val gameSearch = module("gameSearch", Seq(common, hub, search, game)).setti
|
|||
)
|
||||
)
|
||||
|
||||
lazy val tv = module("tv", Seq(common, db, hub, socket, game, user)).settings(
|
||||
lazy val tv = module("tv", Seq(common, db, hub, socket, game, round, user)).settings(
|
||||
libraryDependencies ++= provided(play.api, reactivemongo.driver, hasher)
|
||||
)
|
||||
|
||||
|
|
|
@ -46,9 +46,7 @@ private[tv] final class ChannelActor(channel: Tv.Channel) extends Actor {
|
|||
}
|
||||
}
|
||||
|
||||
def elect(gameOption: Option[Game]): Unit = {
|
||||
gameOption foreach { self ! SetGame(_) }
|
||||
}
|
||||
def elect(gameOption: Option[Game]): Unit = gameOption foreach { self ! SetGame(_) }
|
||||
|
||||
def wayBetter(game: Game, candidates: List[Game]) = feature(candidates) map {
|
||||
case Some(next) if isWayBetter(game, next) => next.some
|
||||
|
|
|
@ -4,6 +4,7 @@ import akka.actor._
|
|||
import com.typesafe.config.Config
|
||||
|
||||
import lila.db.dsl._
|
||||
import lila.game.Game
|
||||
|
||||
import scala.concurrent.duration._
|
||||
|
||||
|
@ -12,6 +13,7 @@ final class Env(
|
|||
db: lila.db.Env,
|
||||
hub: lila.hub.Env,
|
||||
lightUser: lila.common.LightUser.GetterSync,
|
||||
roundProxyGame: Game.ID => Fu[Option[Game]],
|
||||
system: ActorSystem,
|
||||
scheduler: lila.common.Scheduler
|
||||
) {
|
||||
|
@ -21,7 +23,7 @@ final class Env(
|
|||
|
||||
private val selectChannel = system.actorOf(Props(classOf[lila.socket.Channel]), name = ChannelSelect)
|
||||
|
||||
lazy val tv = new Tv(tvActor)
|
||||
lazy val tv = new Tv(tvActor, roundProxyGame)
|
||||
|
||||
private val tvActor =
|
||||
system.actorOf(
|
||||
|
@ -45,6 +47,7 @@ object Env {
|
|||
db = lila.db.Env.current,
|
||||
hub = lila.hub.Env.current,
|
||||
lightUser = lila.user.Env.current.lightUserSync,
|
||||
roundProxyGame = lila.round.Env.current.roundProxyGame _,
|
||||
system = lila.common.PlayApp.system,
|
||||
scheduler = lila.common.PlayApp.scheduler
|
||||
)
|
||||
|
|
|
@ -8,7 +8,7 @@ import akka.pattern.ask
|
|||
import lila.common.LightUser
|
||||
import lila.game.{ Game, GameRepo, Pov }
|
||||
|
||||
final class Tv(actor: ActorRef) {
|
||||
final class Tv(actor: ActorRef, roundProxyGame: Game.ID => Fu[Option[Game]]) {
|
||||
|
||||
import Tv._
|
||||
|
||||
|
@ -19,7 +19,7 @@ final class Tv(actor: ActorRef) {
|
|||
case e: Exception =>
|
||||
logger.warn("Tv.getGame", e)
|
||||
none
|
||||
} flatMap { _ ?? GameRepo.game }
|
||||
} flatMap { _ ?? roundProxyGame }
|
||||
|
||||
def getGameAndHistory(channel: Tv.Channel): Fu[Option[(Game, List[Pov])]] =
|
||||
(actor ? TvActor.GetGameIdAndHistory(channel) mapTo
|
||||
|
@ -29,8 +29,8 @@ final class Tv(actor: ActorRef) {
|
|||
none
|
||||
} flatMap {
|
||||
case ChannelActor.GameIdAndHistory(gameId, historyIds) => for {
|
||||
game <- gameId ?? GameRepo.game
|
||||
games <- GameRepo gamesFromPrimary historyIds
|
||||
game <- gameId ?? roundProxyGame
|
||||
games <- historyIds.map(roundProxyGame).sequenceFu.map(_.flatten)
|
||||
history = games map Pov.first
|
||||
} yield game map (_ -> history)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue