nailed it - closes #2682

This commit is contained in:
Thibault Duplessis 2017-02-17 00:37:22 +01:00
parent 75fdba2f7a
commit 893e3a8e89
11 changed files with 20 additions and 14 deletions

View file

@ -39,7 +39,7 @@ object Account extends LilaController {
Env.pref.api.getPref(me) zip
lila.game.GameRepo.urgentGames(me) zip
Env.challenge.api.countInFor.get(me.id) map {
case ((((nbFollowers, nbFollowing), prefs), povs), nbChallenges) =>
case nbFollowers ~ nbFollowing ~ prefs ~ povs ~ nbChallenges =>
Env.current.bus.publish(lila.user.User.Active(me), 'userActive)
Ok {
import play.api.libs.json._

View file

@ -37,7 +37,7 @@ object Analyse extends LilaController {
Env.game.crosstableApi(pov.game) zip
Env.bookmark.api.exists(pov.game, ctx.me) zip
Env.api.pgnDump(pov.game, initialFen) flatMap {
case ((((((analysis, analysisInProgress), simul), chat), crosstable), bookmarked), pgn) =>
case analysis ~ analysisInProgress ~ simul ~ chat ~ crosstable ~ bookmarked ~ pgn =>
Env.api.roundApi.review(pov, lila.api.Mobile.Api.currentVersion,
tv = none,
analysis,

View file

@ -17,7 +17,7 @@ object Relation extends LilaController {
(ctx.userId ?? { env.api.fetchRelation(_, userId) }) zip
(ctx.isAuth ?? { Env.pref.api followable userId }) zip
(ctx.userId ?? { env.api.fetchBlocks(userId, _) }) flatMap {
case ((relation, followable), blocked) => negotiate(
case relation ~ followable ~ blocked => negotiate(
html = fuccess(Ok(mini.fold(
html.relation.mini(userId, blocked = blocked, followable = followable, relation = relation),
html.relation.actions(userId, relation = relation, blocked = blocked, followable = followable)

View file

@ -56,7 +56,7 @@ object Round extends LilaController with TheftPrevention {
Env.game.crosstableApi(pov.game) zip
(pov.game.isSwitchable ?? otherPovs(pov.game)) zip
Env.bookmark.api.exists(pov.game, ctx.me) flatMap {
case (((((tour, simul), chatOption), crosstable), playing), bookmarked) =>
case tour ~ simul ~ chatOption ~ crosstable ~ playing ~ bookmarked =>
simul foreach Env.simul.api.onPlayerConnection(pov.game, ctx.me)
Env.api.roundApi.player(pov, lila.api.Mobile.Api.currentVersion) map { data =>
Ok(html.round.player(pov, data,
@ -169,7 +169,7 @@ object Round extends LilaController with TheftPrevention {
Env.game.crosstableApi(pov.game) zip
Env.api.roundApi.watcher(pov, lila.api.Mobile.Api.currentVersion, tv = none) zip
Env.bookmark.api.exists(pov.game, ctx.me) map {
case (((((tour, simul), chat), crosstable), data), bookmarked) =>
case tour ~ simul ~ chat ~ crosstable ~ data ~ bookmarked =>
Ok(html.round.watcher(pov, data, tour, simul, crosstable, userTv = userTv, chatOption = chat, bookmarked = bookmarked))
}
else for { // web crawlers don't need the full thing
@ -256,7 +256,7 @@ object Round extends LilaController with TheftPrevention {
GameRepo.initialFen(pov.game) zip
Env.game.crosstableApi(pov.game) zip
Env.bookmark.api.exists(pov.game, ctx.me) map {
case ((((tour, simul), initialFen), crosstable), bookmarked) =>
case tour ~ simul ~ initialFen ~ crosstable ~ bookmarked =>
Ok(html.game.sides(pov, initialFen, tour, crosstable, simul, bookmarked = bookmarked))
}

View file

@ -48,7 +48,7 @@ final class Preload(
streamsOnAir() zip
(ctx.userId ?? getPlayban) zip
(ctx.me ?? Preload.currentGame(lightUserApi.sync)) flatMap {
case (((((((((((((data, posts), tours), events), simuls), feat), entries), lead), tWinners), puzzle), streams), playban), currentGame)) =>
case data ~ posts ~ tours ~ events ~ simuls ~ feat ~ entries ~ lead ~ tWinners ~ puzzle ~ streams ~ playban ~ currentGame =>
lightUserApi.preloadMany {
tWinners.map(_.userId) :::
posts.flatMap(_.userId) :::

View file

@ -98,7 +98,7 @@ object UserInfo {
(user.count.rated >= 10).??(insightShare.grant(user, ctx.me)) zip
completionRate(user.id) zip
bookmarkApi.countByUser(user) flatMap {
case (((((((((((((((ranks, nbPlaying), nbImported), crosstable), ratingChart), nbFollowers), nbBlockers), nbPosts), nbStudies), trophies), teamIds), isCoach), isStreamer), insightVisible), completionRate), nbBookmarks) =>
case ranks ~ nbPlaying ~ nbImported ~ crosstable ~ ratingChart ~ nbFollowers ~ nbBlockers ~ nbPosts ~ nbStudies ~ trophies ~ teamIds ~ isCoach ~ isStreamer ~ insightVisible ~ completionRate ~ nbBookmarks =>
(nbPlaying > 0) ?? isHostingSimul(user.id) map { hasSimul =>
new UserInfo(
user = user,

View file

@ -33,7 +33,7 @@ private[api] final class RoundApi(
(ctx.me.ifTrue(ctx.isMobileApi) ?? (me => noteApi.get(pov.gameId, me.id))) zip
forecastApi.loadForDisplay(pov) zip
bookmarkApi.exists(pov.game, ctx.me) map {
case (((((json, tourOption), simulOption), note), forecast), bookmarked) => (
case json ~ tourOption ~ simulOption ~ note ~ forecast ~ bookmarked => (
blindMode _ compose
withTournament(pov, tourOption)_ compose
withSimul(pov, simulOption)_ compose
@ -57,7 +57,7 @@ private[api] final class RoundApi(
(pov.game.simulId ?? getSimul) zip
(ctx.me.ifTrue(ctx.isMobileApi) ?? (me => noteApi.get(pov.gameId, me.id))) zip
bookmarkApi.exists(pov.game, ctx.me) map {
case ((((json, tourOption), simulOption), note), bookmarked) => (
case json ~ tourOption ~ simulOption ~ note ~ bookmarked => (
blindMode _ compose
withTournament(pov, tourOption)_ compose
withSimul(pov, simulOption)_ compose
@ -85,7 +85,7 @@ private[api] final class RoundApi(
(pov.game.simulId ?? getSimul) zip
(ctx.me.ifTrue(ctx.isMobileApi) ?? (me => noteApi.get(pov.gameId, me.id))) zip
bookmarkApi.exists(pov.game, ctx.me) map {
case ((((json, tourOption), simulOption), note), bookmarked) => (
case json ~ tourOption ~ simulOption ~ note ~ bookmarked => (
blindMode _ compose
withTournament(pov, tourOption)_ compose
withSimul(pov, simulOption)_ compose

View file

@ -34,7 +34,7 @@ private[api] final class UserApi(
bookmarkApi.countByUser(u) zip
gameCache.nbPlaying(u.id) zip
gameCache.nbImportedBy(u.id) map {
case (((((((((gameOption, nbGamesWithMe), following), followers), followable), relation), isFollowed), nbBookmarks), nbPlaying), nbImported) =>
case gameOption ~ nbGamesWithMe ~ following ~ followers ~ followable ~ relation ~ isFollowed ~ nbBookmarks ~ nbPlaying ~ nbImported =>
jsonView(u) ++ {
Json.obj(
"url" -> makeUrl(s"@/$username"),

View file

@ -32,6 +32,12 @@ trait PackageObject extends Steroids with WithFuture {
def apply[A](a: M[Option[A]]) = new OptionT[M, A](a)
}
type ~[+A, +B] = Tuple2[A, B]
object ~ {
def apply[A, B](x: A, y: B) = Tuple2(x, y)
def unapply[A, B](x: Tuple2[A, B]): Option[Tuple2[A, B]] = Some(x)
}
implicit final class LilaPimpedString(s: String) {
def boot[A](v: => A): A = lila.common.Chronometer.syncEffect(v) { lap =>

View file

@ -85,7 +85,7 @@ object PovToEntry {
}
}
movetimes.zip(roles).zip(boards).zipWithIndex.map {
case (((tenths, role), board), i) =>
case tenths ~ role ~ board ~ i =>
val ply = i * 2 + from.pov.color.fold(1, 2)
val prevInfo = prevInfos lift i
val opportunism = from.advices.get(ply - 1) flatMap {

View file

@ -55,7 +55,7 @@ final class AssessApi(
getPlayerAssessmentsByUserId(userId, nb) zip
relatedUsers zip
(relatedUsers flatMap UserRepo.filterByEngine) map {
case (((Some(user), assessedGamesHead :: assessedGamesTail), relatedUs), relatedCheaters) =>
case Some(user) ~ (assessedGamesHead :: assessedGamesTail) ~ relatedUs ~ relatedCheaters =>
Some(PlayerAggregateAssessment(
user,
assessedGamesHead :: assessedGamesTail,