This commit is contained in:
Thibault Duplessis 2018-04-20 06:41:31 +02:00
parent eb4be3f8ba
commit e33dba2551
2 changed files with 8 additions and 7 deletions

View file

@ -22,18 +22,19 @@ final class Tv(actor: ActorRef, roundProxyGame: Game.ID => Fu[Option[Game]]) {
} flatMap { _ ?? roundProxyGame } } flatMap { _ ?? roundProxyGame }
def getGameAndHistory(channel: Tv.Channel): Fu[Option[(Game, List[Pov])]] = def getGameAndHistory(channel: Tv.Channel): Fu[Option[(Game, List[Pov])]] =
(actor ? TvActor.GetGameIdAndHistory(channel) mapTo (actor ? TvActor.GetGameIdAndHistory(channel) mapTo manifest[ChannelActor.GameIdAndHistory]).map(some) recover {
manifest[ChannelActor.GameIdAndHistory]) recover { case e: Exception =>
case e: Exception => logger.warn("Tv.getGame", e)
logger.warn("Tv.getGame", e) none
none } flatMap {
} flatMap { _ ?? {
case ChannelActor.GameIdAndHistory(gameId, historyIds) => for { case ChannelActor.GameIdAndHistory(gameId, historyIds) => for {
game <- gameId ?? roundProxyGame game <- gameId ?? roundProxyGame
games <- historyIds.map(roundProxyGame).sequenceFu.map(_.flatten) games <- historyIds.map(roundProxyGame).sequenceFu.map(_.flatten)
history = games map Pov.first history = games map Pov.first
} yield game map (_ -> history) } yield game map (_ -> history)
} }
}
def getGames(channel: Tv.Channel, max: Int): Fu[List[Game]] = def getGames(channel: Tv.Channel, max: Int): Fu[List[Game]] =
(actor ? TvActor.GetGameIds(channel, max) mapTo manifest[List[Game.ID]]) recover { (actor ? TvActor.GetGameIds(channel, max) mapTo manifest[List[Game.ID]]) recover {

View file

@ -21,7 +21,7 @@ private[tv] final class TvActor(
implicit private def timeout = makeTimeout(100 millis) implicit private def timeout = makeTimeout(100 millis)
val channelActors: Map[Tv.Channel, ActorRef] = Tv.Channel.all.map { c => val channelActors: Map[Tv.Channel, ActorRef] = Tv.Channel.all.map { c =>
c -> context.actorOf(Props(classOf[ChannelActor], c), name = c.toString) c -> context.actorOf(Props(classOf[ChannelActor], c, lightUser), name = c.toString)
}.toMap }.toMap
var channelChampions = Map[Tv.Channel, Tv.Champion]() var channelChampions = Map[Tv.Channel, Tv.Champion]()