pull/4302/head
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 }
def getGameAndHistory(channel: Tv.Channel): Fu[Option[(Game, List[Pov])]] =
(actor ? TvActor.GetGameIdAndHistory(channel) mapTo
manifest[ChannelActor.GameIdAndHistory]) recover {
case e: Exception =>
logger.warn("Tv.getGame", e)
none
} flatMap {
(actor ? TvActor.GetGameIdAndHistory(channel) mapTo manifest[ChannelActor.GameIdAndHistory]).map(some) recover {
case e: Exception =>
logger.warn("Tv.getGame", e)
none
} flatMap {
_ ?? {
case ChannelActor.GameIdAndHistory(gameId, historyIds) => for {
game <- gameId ?? roundProxyGame
games <- historyIds.map(roundProxyGame).sequenceFu.map(_.flatten)
history = games map Pov.first
} yield game map (_ -> history)
}
}
def getGames(channel: Tv.Channel, max: Int): Fu[List[Game]] =
(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)
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
var channelChampions = Map[Tv.Channel, Tv.Champion]()