scalafmt 2.7.1
parent
c794d88af9
commit
aaf88bc62c
|
@ -1,4 +1,4 @@
|
|||
version = "2.6.3"
|
||||
version = "2.7.1"
|
||||
align.preset = more
|
||||
maxColumn = 110
|
||||
spaces.inImportCurlyBraces = true
|
||||
|
|
|
@ -130,8 +130,7 @@ final class Env(
|
|||
Future {
|
||||
puzzle.daily.get
|
||||
}.flatMap(identity)
|
||||
.withTimeoutDefault(50.millis, none) recover {
|
||||
case e: Exception =>
|
||||
.withTimeoutDefault(50.millis, none) recover { case e: Exception =>
|
||||
lila.log("preloader").warn("daily puzzle", e)
|
||||
none
|
||||
}
|
||||
|
@ -163,8 +162,7 @@ final class Env(
|
|||
}
|
||||
} yield Bus.publish(lila.hub.actorApi.security.CloseAccount(u.id), "accountClose")
|
||||
|
||||
Bus.subscribeFun("garbageCollect") {
|
||||
case lila.hub.actorApi.security.GarbageCollect(userId) =>
|
||||
Bus.subscribeFun("garbageCollect") { case lila.hub.actorApi.security.GarbageCollect(userId) =>
|
||||
// GC can be aborted by reverting the initial SB mark
|
||||
user.repo.isTroll(userId) foreach { troll =>
|
||||
if (troll) scheduler.scheduleOnce(1.second) {
|
||||
|
|
|
@ -44,8 +44,7 @@ final class Account(
|
|||
} { username =>
|
||||
env.user.repo
|
||||
.setUsernameCased(me.id, username) inject
|
||||
Redirect(routes.User show me.username).flashSuccess recover {
|
||||
case e =>
|
||||
Redirect(routes.User show me.username).flashSuccess recover { case e =>
|
||||
BadRequest(html.account.username(me, env.user.forms.username(me))).flashFailure(e.getMessage)
|
||||
}
|
||||
}
|
||||
|
@ -201,8 +200,7 @@ final class Account(
|
|||
def emailConfirm(token: String) =
|
||||
Open { implicit ctx =>
|
||||
env.security.emailChange.confirm(token) flatMap {
|
||||
_ ?? {
|
||||
case (user, prevEmail) =>
|
||||
_ ?? { case (user, prevEmail) =>
|
||||
(prevEmail.exists(_.isNoReply) ?? env.clas.api.student.release(user)) >>
|
||||
auth.authenticateUser(
|
||||
user,
|
||||
|
|
|
@ -50,8 +50,7 @@ final class Analyse(
|
|||
initialFen,
|
||||
analysis = none,
|
||||
PgnDump.WithFlags(clocks = false)
|
||||
) flatMap {
|
||||
case analysis ~ analysisInProgress ~ simul ~ chat ~ crosstable ~ bookmarked ~ pgn =>
|
||||
) flatMap { case analysis ~ analysisInProgress ~ simul ~ chat ~ crosstable ~ bookmarked ~ pgn =>
|
||||
env.api.roundApi.review(
|
||||
pov,
|
||||
lila.api.Mobile.Api.currentVersion,
|
||||
|
|
|
@ -106,8 +106,7 @@ final class Auth(
|
|||
),
|
||||
usernameOrEmail =>
|
||||
HasherRateLimit(usernameOrEmail, ctx.req) { chargeIpLimiter =>
|
||||
api.loadLoginForm(usernameOrEmail) flatMap {
|
||||
loginForm =>
|
||||
api.loadLoginForm(usernameOrEmail) flatMap { loginForm =>
|
||||
loginForm
|
||||
.bindFromRequest()
|
||||
.fold(
|
||||
|
@ -247,8 +246,7 @@ final class Auth(
|
|||
err => BadRequest(html.auth.checkYourEmail(userEmail.some, err.some)).fuccess,
|
||||
email =>
|
||||
env.user.repo.named(userEmail.username) flatMap {
|
||||
_.fold(Redirect(routes.Auth.signup()).fuccess) {
|
||||
user =>
|
||||
_.fold(Redirect(routes.Auth.signup()).fuccess) { user =>
|
||||
env.user.repo.mustConfirmEmail(user.id) flatMap {
|
||||
case false => Redirect(routes.Auth.login()).fuccess
|
||||
case _ =>
|
||||
|
|
|
@ -239,8 +239,7 @@ final class Challenge(
|
|||
val cost = if (me.isApiHog) 0 else 1
|
||||
ChallengeIpRateLimit(HTTPRequest lastRemoteAddress req, cost = cost) {
|
||||
ChallengeUserRateLimit(me.id, cost = cost) {
|
||||
env.user.repo enabledById userId.toLowerCase flatMap {
|
||||
destUser =>
|
||||
env.user.repo enabledById userId.toLowerCase flatMap { destUser =>
|
||||
import lila.challenge.Challenge._
|
||||
val timeControl = config.clock map {
|
||||
TimeControl.Clock.apply
|
||||
|
|
|
@ -204,8 +204,7 @@ final class Clas(
|
|||
val studentIds = students.map(_.user.id)
|
||||
env.learn.api.completionPercent(studentIds) zip
|
||||
env.practice.api.progress.completionPercent(studentIds) zip
|
||||
env.coordinate.api.bestScores(studentIds) map {
|
||||
case basic ~ practice ~ coords =>
|
||||
env.coordinate.api.bestScores(studentIds) map { case basic ~ practice ~ coords =>
|
||||
views.html.clas.teacherDashboard.learn(clas, students, basic, practice, coords)
|
||||
}
|
||||
}
|
||||
|
@ -321,8 +320,7 @@ final class Clas(
|
|||
case _ => none
|
||||
}
|
||||
}
|
||||
.map {
|
||||
case (u, p) =>
|
||||
.map { case (u, p) =>
|
||||
env.clas.api.student
|
||||
.get(clas, u)
|
||||
.map2(lila.clas.Student.WithPassword(_, lila.user.User.ClearPassword(p)))
|
||||
|
@ -389,11 +387,9 @@ final class Clas(
|
|||
},
|
||||
data =>
|
||||
env.user.repo named data.username flatMap {
|
||||
_ ?? {
|
||||
user =>
|
||||
_ ?? { user =>
|
||||
import lila.clas.ClasInvite.{ Feedback => F }
|
||||
env.clas.api.invite.create(clas, user, data.realName, me) map {
|
||||
feedback =>
|
||||
env.clas.api.invite.create(clas, user, data.realName, me) map { feedback =>
|
||||
Redirect(routes.Clas.studentForm(clas.id.value)).flashing {
|
||||
feedback match {
|
||||
case F.Already => "success" -> s"${user.username} is now a student of the class"
|
||||
|
@ -529,8 +525,8 @@ final class Clas(
|
|||
|
||||
def invitation(id: String) =
|
||||
Auth { implicit ctx => me =>
|
||||
OptionOk(env.clas.api.invite.view(lila.clas.ClasInvite.Id(id), me)) {
|
||||
case (invite -> clas) => views.html.clas.invite.show(clas, invite)
|
||||
OptionOk(env.clas.api.invite.view(lila.clas.ClasInvite.Id(id), me)) { case (invite -> clas) =>
|
||||
views.html.clas.invite.show(clas, invite)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -127,8 +127,8 @@ final class Coach(env: Env) extends LilaController(env) {
|
|||
OptionFuResult(api findOrInit me) { c =>
|
||||
ctx.body.body.file("picture") match {
|
||||
case Some(pic) =>
|
||||
api.uploadPicture(c, pic) recover {
|
||||
case e: lila.base.LilaException => BadRequest(html.coach.picture(c, e.message.some))
|
||||
api.uploadPicture(c, pic) recover { case e: lila.base.LilaException =>
|
||||
BadRequest(html.coach.picture(c, e.message.some))
|
||||
} inject Redirect(routes.Coach.edit())
|
||||
case None => fuccess(Redirect(routes.Coach.edit()))
|
||||
}
|
||||
|
|
|
@ -28,8 +28,7 @@ final class Export(env: Env) extends LilaController(env) {
|
|||
Open { implicit ctx =>
|
||||
OnlyHumansAndFacebookOrTwitter {
|
||||
ExportGifRateLimitGlobal("-", msg = HTTPRequest.lastRemoteAddress(ctx.req).value) {
|
||||
OptionFuResult(env.game.gameRepo gameWithInitialFen id) {
|
||||
case (game, initialFen) =>
|
||||
OptionFuResult(env.game.gameRepo gameWithInitialFen id) { case (game, initialFen) =>
|
||||
val pov = Pov(game, Color(color) | Color.white)
|
||||
env.game.gifExport.fromPov(pov, initialFen) map
|
||||
stream("image/gif") map
|
||||
|
|
|
@ -21,8 +21,7 @@ final class ForumCateg(env: Env) extends LilaController(env) with ForumControlle
|
|||
Open { implicit ctx =>
|
||||
NotForKids {
|
||||
Reasonable(page, 50, errorPage = notFound) {
|
||||
OptionFuOk(categApi.show(slug, page, ctx.me)) {
|
||||
case (categ, topics) =>
|
||||
OptionFuOk(categApi.show(slug, page, ctx.me)) { case (categ, topics) =>
|
||||
for {
|
||||
canWrite <- isGrantedWrite(categ.slug)
|
||||
stickyPosts <- (page == 1) ?? env.forum.topicApi.getSticky(categ, ctx.me)
|
||||
|
|
|
@ -23,8 +23,7 @@ final class ForumPost(env: Env) extends LilaController(env) with ForumController
|
|||
NoBot {
|
||||
CategGrantWrite(categSlug) {
|
||||
implicit val req = ctx.body
|
||||
OptionFuResult(topicApi.show(categSlug, slug, page, ctx.me)) {
|
||||
case (categ, topic, posts) =>
|
||||
OptionFuResult(topicApi.show(categSlug, slug, page, ctx.me)) { case (categ, topic, posts) =>
|
||||
if (topic.closed) fuccess(BadRequest("This topic is closed"))
|
||||
else if (topic.isOld) fuccess(BadRequest("This topic is archived"))
|
||||
else
|
||||
|
@ -88,8 +87,7 @@ final class ForumPost(env: Env) extends LilaController(env) with ForumController
|
|||
|
||||
def redirect(id: String) =
|
||||
Open { implicit ctx =>
|
||||
OptionResult(postApi.urlData(id, ctx.me)) {
|
||||
case lila.forum.PostUrlData(categ, topic, page, number) =>
|
||||
OptionResult(postApi.urlData(id, ctx.me)) { case lila.forum.PostUrlData(categ, topic, page, number) =>
|
||||
Redirect(routes.ForumTopic.show(categ, topic, page).url + "#" + number)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,8 +52,7 @@ final class ForumTopic(env: Env) extends LilaController(env) with ForumControlle
|
|||
def show(categSlug: String, slug: String, page: Int) =
|
||||
Open { implicit ctx =>
|
||||
NotForKids {
|
||||
OptionFuOk(topicApi.show(categSlug, slug, page, ctx.me)) {
|
||||
case (categ, topic, posts) =>
|
||||
OptionFuOk(topicApi.show(categSlug, slug, page, ctx.me)) { case (categ, topic, posts) =>
|
||||
for {
|
||||
unsub <- ctx.userId ?? env.timeline.status(s"forum:${topic.id}")
|
||||
canWrite <- isGrantedWrite(categSlug)
|
||||
|
@ -70,8 +69,7 @@ final class ForumTopic(env: Env) extends LilaController(env) with ForumControlle
|
|||
def close(categSlug: String, slug: String) =
|
||||
Auth { implicit ctx => me =>
|
||||
CategGrantMod(categSlug) {
|
||||
OptionFuRedirect(topicApi.show(categSlug, slug, 1, ctx.me)) {
|
||||
case (categ, topic, pag) =>
|
||||
OptionFuRedirect(topicApi.show(categSlug, slug, 1, ctx.me)) { case (categ, topic, pag) =>
|
||||
topicApi.toggleClose(categ, topic, me) inject
|
||||
routes.ForumTopic.show(categSlug, slug, pag.nbPages)
|
||||
}
|
||||
|
@ -80,8 +78,7 @@ final class ForumTopic(env: Env) extends LilaController(env) with ForumControlle
|
|||
|
||||
def hide(categSlug: String, slug: String) =
|
||||
Secure(_.ModerateForum) { implicit ctx => me =>
|
||||
OptionFuRedirect(topicApi.show(categSlug, slug, 1, ctx.me)) {
|
||||
case (categ, topic, pag) =>
|
||||
OptionFuRedirect(topicApi.show(categSlug, slug, 1, ctx.me)) { case (categ, topic, pag) =>
|
||||
topicApi.toggleHide(categ, topic, me) inject
|
||||
routes.ForumTopic.show(categSlug, slug, pag.nbPages)
|
||||
}
|
||||
|
@ -90,8 +87,7 @@ final class ForumTopic(env: Env) extends LilaController(env) with ForumControlle
|
|||
def sticky(categSlug: String, slug: String) =
|
||||
Auth { implicit ctx => me =>
|
||||
CategGrantMod(categSlug) {
|
||||
OptionFuRedirect(topicApi.show(categSlug, slug, 1, ctx.me)) {
|
||||
case (categ, topic, pag) =>
|
||||
OptionFuRedirect(topicApi.show(categSlug, slug, 1, ctx.me)) { case (categ, topic, pag) =>
|
||||
topicApi.toggleSticky(categ, topic, me) inject
|
||||
routes.ForumTopic.show(categSlug, slug, pag.nbPages)
|
||||
}
|
||||
|
|
|
@ -90,8 +90,7 @@ final class Importer(env: Env) extends LilaController(env) {
|
|||
): Fu[Option[lila.game.Game]] =
|
||||
env.importer.importer(data, me.map(_.id)) flatMap { game =>
|
||||
me.map(_.id).??(env.game.cached.clearNbImportedByCache) inject game.some
|
||||
} recover {
|
||||
case e: Exception =>
|
||||
} recover { case e: Exception =>
|
||||
lila
|
||||
.log("importer")
|
||||
.warn(s"Imported game validates but can't be replayed:\n${data.pgn}", e)
|
||||
|
|
|
@ -38,8 +38,7 @@ final class Learn(env: Env) extends LilaController(env) {
|
|||
.bindFromRequest()
|
||||
.fold(
|
||||
_ => BadRequest.fuccess,
|
||||
{
|
||||
case (stage, level, s) =>
|
||||
{ case (stage, level, s) =>
|
||||
val score = lila.learn.StageProgress.Score(s)
|
||||
env.learn.api.setScore(me, stage, level, score) >>
|
||||
env.activity.write.learn(me.id, stage) inject Ok(Json.obj("ok" -> true))
|
||||
|
|
|
@ -483,16 +483,14 @@ abstract private[controllers] class LilaController(val env: Env)
|
|||
.dmap(_.withHeaders("Vary" -> "Accept"))
|
||||
|
||||
protected def reqToCtx(req: RequestHeader): Fu[HeaderContext] =
|
||||
restoreUser(req) flatMap {
|
||||
case (d, impersonatedBy) =>
|
||||
restoreUser(req) flatMap { case (d, impersonatedBy) =>
|
||||
val lang = getAndSaveLang(req, d.map(_.user))
|
||||
val ctx = UserContext(req, d.map(_.user), impersonatedBy, lang)
|
||||
pageDataBuilder(ctx, d.exists(_.hasFingerPrint)) dmap { Context(ctx, _) }
|
||||
}
|
||||
|
||||
protected def reqToCtx[A](req: Request[A]): Fu[BodyContext[A]] =
|
||||
restoreUser(req) flatMap {
|
||||
case (d, impersonatedBy) =>
|
||||
restoreUser(req) flatMap { case (d, impersonatedBy) =>
|
||||
val lang = getAndSaveLang(req, d.map(_.user))
|
||||
val ctx = UserContext(req, d.map(_.user), impersonatedBy, lang)
|
||||
pageDataBuilder(ctx, d.exists(_.hasFingerPrint)) dmap { Context(ctx, _) }
|
||||
|
|
|
@ -33,8 +33,7 @@ final class Main(
|
|||
.bindFromRequest()
|
||||
.fold(
|
||||
_ => BadRequest,
|
||||
{
|
||||
case (enable, redirect) =>
|
||||
{ case (enable, redirect) =>
|
||||
Redirect(redirect) withCookies env.lilaCookie.cookie(
|
||||
env.api.config.accessibility.blindCookieName,
|
||||
if (enable == "0") "" else env.api.config.accessibility.hash,
|
||||
|
@ -50,8 +49,8 @@ final class Main(
|
|||
|
||||
def captchaCheck(id: String) =
|
||||
Open { implicit ctx =>
|
||||
env.hub.captcher.actor ? ValidCaptcha(id, ~get("solution")) map {
|
||||
case valid: Boolean => Ok(if (valid) 1 else 0)
|
||||
env.hub.captcher.actor ? ValidCaptcha(id, ~get("solution")) map { case valid: Boolean =>
|
||||
Ok(if (valid) 1 else 0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,8 +73,8 @@ final class Main(
|
|||
def mobile =
|
||||
Open { implicit ctx =>
|
||||
pageHit
|
||||
OptionOk(prismicC getBookmark "mobile-apk") {
|
||||
case (doc, resolver) => html.mobile(doc, resolver)
|
||||
OptionOk(prismicC getBookmark "mobile-apk") { case (doc, resolver) =>
|
||||
html.mobile(doc, resolver)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@ final class Mod(
|
|||
} yield (inquiry, sus).some
|
||||
}
|
||||
}(ctx =>
|
||||
me => {
|
||||
case (inquiry, suspect) => reportC.onInquiryClose(inquiry, me, suspect.some)(ctx)
|
||||
me => { case (inquiry, suspect) =>
|
||||
reportC.onInquiryClose(inquiry, me, suspect.some)(ctx)
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -50,15 +50,14 @@ final class Mod(
|
|||
} yield (inquiry, sus).some
|
||||
}
|
||||
}(ctx =>
|
||||
me => {
|
||||
case (inquiry, suspect) => reportC.onInquiryClose(inquiry, me, suspect.some)(ctx)
|
||||
me => { case (inquiry, suspect) =>
|
||||
reportC.onInquiryClose(inquiry, me, suspect.some)(ctx)
|
||||
}
|
||||
)
|
||||
|
||||
def publicChat =
|
||||
Secure(_.ChatTimeout) { implicit ctx => _ =>
|
||||
env.mod.publicChat.all map {
|
||||
case (tournamentsAndChats, simulsAndChats) =>
|
||||
env.mod.publicChat.all map { case (tournamentsAndChats, simulsAndChats) =>
|
||||
Ok(html.mod.publicChat(tournamentsAndChats, simulsAndChats))
|
||||
}
|
||||
}
|
||||
|
@ -72,8 +71,8 @@ final class Mod(
|
|||
} yield (inquiry, suspect).some
|
||||
}
|
||||
}(ctx =>
|
||||
me => {
|
||||
case (inquiry, suspect) => reportC.onInquiryClose(inquiry, me, suspect.some)(ctx)
|
||||
me => { case (inquiry, suspect) =>
|
||||
reportC.onInquiryClose(inquiry, me, suspect.some)(ctx)
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -86,8 +85,8 @@ final class Mod(
|
|||
} yield (inquiry, suspect).some
|
||||
}
|
||||
}(ctx =>
|
||||
me => {
|
||||
case (inquiry, suspect) => reportC.onInquiryClose(inquiry, me, suspect.some)(ctx)
|
||||
me => { case (inquiry, suspect) =>
|
||||
reportC.onInquiryClose(inquiry, me, suspect.some)(ctx)
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -104,8 +103,8 @@ final class Mod(
|
|||
}
|
||||
}
|
||||
}(ctx =>
|
||||
me => {
|
||||
case (inquiry, suspect) => reportC.onInquiryClose(inquiry, me, suspect.some)(ctx)
|
||||
me => { case (inquiry, suspect) =>
|
||||
reportC.onInquiryClose(inquiry, me, suspect.some)(ctx)
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -250,7 +249,11 @@ final class Mod(
|
|||
if (!inquiry.??(_.isRecentCommOf(Suspect(user))))
|
||||
env.slack.api.commlog(mod = me, user = user, inquiry.map(_.oldestAtom.by.value))
|
||||
if (isGranted(_.MonitoredMod))
|
||||
env.slack.api.monitorMod(me.id, "eyes", s"checked out @${user.username}'s private comms")
|
||||
env.slack.api.monitorMod(
|
||||
me.id,
|
||||
"eyes",
|
||||
s"checked out @${user.username}'s private comms"
|
||||
)
|
||||
}
|
||||
html.mod.communication(
|
||||
user,
|
||||
|
@ -305,8 +308,8 @@ final class Mod(
|
|||
def gamify =
|
||||
Secure(_.SeeReport) { implicit ctx => _ =>
|
||||
env.mod.gamify.leaderboards zip
|
||||
env.mod.gamify.history(orCompute = true) map {
|
||||
case (leaderboards, history) => Ok(html.mod.gamify.index(leaderboards, history))
|
||||
env.mod.gamify.history(orCompute = true) map { case (leaderboards, history) =>
|
||||
Ok(html.mod.gamify.index(leaderboards, history))
|
||||
}
|
||||
}
|
||||
def gamifyPeriod(periodStr: String) =
|
||||
|
|
|
@ -13,8 +13,7 @@ final class Msg(
|
|||
def home =
|
||||
Auth { implicit ctx => me =>
|
||||
negotiate(
|
||||
html =
|
||||
inboxJson(me) map { json =>
|
||||
html = inboxJson(me) map { json =>
|
||||
Ok(views.html.msg.home(json))
|
||||
},
|
||||
api = v =>
|
||||
|
@ -38,8 +37,7 @@ final class Msg(
|
|||
case Some(c) =>
|
||||
def newJson = inboxJson(me).map { _ + ("convo" -> env.msg.json.convo(c)) }
|
||||
negotiate(
|
||||
html =
|
||||
newJson map { json =>
|
||||
html = newJson map { json =>
|
||||
Ok(views.html.msg.home(json))
|
||||
},
|
||||
api = v =>
|
||||
|
|
|
@ -18,8 +18,8 @@ final class Page(
|
|||
private def helpBookmark(name: String) =
|
||||
Open { implicit ctx =>
|
||||
pageHit
|
||||
OptionOk(prismicC getBookmark name) {
|
||||
case (doc, resolver) => views.html.site.help.page(name, doc, resolver)
|
||||
OptionOk(prismicC getBookmark name) { case (doc, resolver) =>
|
||||
views.html.site.help.page(name, doc, resolver)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,16 +28,16 @@ final class Page(
|
|||
private def bookmark(name: String) =
|
||||
Open { implicit ctx =>
|
||||
pageHit
|
||||
OptionOk(prismicC getBookmark name) {
|
||||
case (doc, resolver) => views.html.site.page(doc, resolver)
|
||||
OptionOk(prismicC getBookmark name) { case (doc, resolver) =>
|
||||
views.html.site.page(doc, resolver)
|
||||
}
|
||||
}
|
||||
|
||||
def source =
|
||||
Open { implicit ctx =>
|
||||
pageHit
|
||||
OptionOk(prismicC getBookmark "source") {
|
||||
case (doc, resolver) => views.html.site.help.source(doc, resolver)
|
||||
OptionOk(prismicC getBookmark "source") { case (doc, resolver) =>
|
||||
views.html.site.help.source(doc, resolver)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -45,8 +45,8 @@ final class Page(
|
|||
Open { implicit ctx =>
|
||||
import play.api.libs.json._
|
||||
negotiate(
|
||||
html = OptionOk(prismicC getBookmark "variant") {
|
||||
case (doc, resolver) => views.html.site.variant.home(doc, resolver)
|
||||
html = OptionOk(prismicC getBookmark "variant") { case (doc, resolver) =>
|
||||
views.html.site.variant.home(doc, resolver)
|
||||
},
|
||||
api = _ =>
|
||||
Ok(JsArray(chess.variant.Variant.all.map { v =>
|
||||
|
@ -64,8 +64,8 @@ final class Page(
|
|||
(for {
|
||||
variant <- chess.variant.Variant.byKey get key
|
||||
perfType <- lila.rating.PerfType byVariant variant
|
||||
} yield OptionOk(prismicC getVariant variant) {
|
||||
case (doc, resolver) => views.html.site.variant.show(doc, resolver, variant, perfType)
|
||||
} yield OptionOk(prismicC getVariant variant) { case (doc, resolver) =>
|
||||
views.html.site.variant.show(doc, resolver, variant, perfType)
|
||||
}) | notFound
|
||||
}
|
||||
}
|
||||
|
|
|
@ -135,8 +135,7 @@ final class Plan(env: Env)(implicit system: akka.actor.ActorSystem) extends Lila
|
|||
}
|
||||
|
||||
def badStripeSession[A: Writes](err: A) = BadRequest(jsonError(err))
|
||||
def badStripeApiCall: PartialFunction[Throwable, Result] = {
|
||||
case e: StripeException =>
|
||||
def badStripeApiCall: PartialFunction[Throwable, Result] = { case e: StripeException =>
|
||||
logger.error("Plan.stripeCheckout", e)
|
||||
badStripeSession("Stripe API call failed")
|
||||
}
|
||||
|
|
|
@ -40,8 +40,8 @@ final class PlayApi(
|
|||
env.user.repo.setBot(me) >>
|
||||
env.pref.api.setBot(me) >>-
|
||||
env.user.lightUserApi.invalidate(me.id) pipe
|
||||
toResult recover {
|
||||
case lila.base.LilaInvalid(msg) => BadRequest(jsonError(msg))
|
||||
toResult recover { case lila.base.LilaInvalid(msg) =>
|
||||
BadRequest(jsonError(msg))
|
||||
}
|
||||
}
|
||||
case _ => impl.command(me, cmd)(WithPovAsBot)
|
||||
|
@ -111,8 +111,8 @@ final class PlayApi(
|
|||
|
||||
private def toResult(f: Funit): Fu[Result] = catchClientError(f inject jsonOkResult)
|
||||
private def catchClientError(f: Fu[Result]): Fu[Result] =
|
||||
f recover {
|
||||
case e: lila.round.BenignError => BadRequest(jsonError(e.getMessage))
|
||||
f recover { case e: lila.round.BenignError =>
|
||||
BadRequest(jsonError(e.getMessage))
|
||||
}
|
||||
|
||||
private def WithPovAsBot(anyId: String, me: lila.user.User)(f: Pov => Fu[Result]) =
|
||||
|
|
|
@ -64,8 +64,7 @@ final class Practice(
|
|||
}
|
||||
|
||||
private def showUserPractice(us: lila.practice.UserStudy)(implicit ctx: Context) =
|
||||
analysisJson(us) map {
|
||||
case (analysisJson, studyJson) =>
|
||||
analysisJson(us) map { case (analysisJson, studyJson) =>
|
||||
NoCache(
|
||||
EnableSharedArrayBuffer(
|
||||
Ok(
|
||||
|
@ -85,8 +84,7 @@ final class Practice(
|
|||
def chapter(studyId: String, chapterId: String) =
|
||||
Open { implicit ctx =>
|
||||
OptionFuResult(api.getStudyWithChapter(ctx.me, studyId, chapterId)) { us =>
|
||||
analysisJson(us) map {
|
||||
case (analysisJson, studyJson) =>
|
||||
analysisJson(us) map { case (analysisJson, studyJson) =>
|
||||
Ok(
|
||||
Json.obj(
|
||||
"study" -> studyJson,
|
||||
|
|
|
@ -55,8 +55,7 @@ final class Pref(env: Env) extends LilaController(env) {
|
|||
Ok.withCookies(env.lilaCookie.session("zoom2", (getInt("v") | 185).toString)).fuccess
|
||||
} else {
|
||||
implicit val req = ctx.body
|
||||
(setters get name) ?? {
|
||||
case (form, fn) =>
|
||||
(setters get name) ?? { case (form, fn) =>
|
||||
FormResult(form) { v =>
|
||||
fn(v, ctx) map { cookie =>
|
||||
Ok(()).withCookies(cookie)
|
||||
|
|
|
@ -33,8 +33,7 @@ final class Prismic(
|
|||
api.bookmarks.get(name) ?? getDocument map2 { (doc: io.prismic.Document) =>
|
||||
doc -> makeLinkResolver(api)
|
||||
}
|
||||
} recover {
|
||||
case e: Exception =>
|
||||
} recover { case e: Exception =>
|
||||
logger.error(s"bookmark:$name", e)
|
||||
none
|
||||
}
|
||||
|
|
|
@ -188,8 +188,7 @@ final class Puzzle(
|
|||
vote =>
|
||||
env.puzzle.api.vote.find(id, me) flatMap { v =>
|
||||
env.puzzle.api.vote.update(id, me, v, vote == 1)
|
||||
} map {
|
||||
case (p, a) =>
|
||||
} map { case (p, a) =>
|
||||
if (vote == 1) lila.mon.puzzle.vote.up.increment()
|
||||
else lila.mon.puzzle.vote.down.increment()
|
||||
Ok(Json.arr(a.value, p.vote.sum))
|
||||
|
|
|
@ -21,8 +21,7 @@ final class Relation(
|
|||
private def renderActions(userId: String, mini: Boolean)(implicit ctx: Context) =
|
||||
(ctx.userId ?? { api.fetchRelation(_, userId) }) zip
|
||||
(ctx.isAuth ?? { env.pref.api followable userId }) zip
|
||||
(ctx.userId ?? { api.fetchBlocks(userId, _) }) flatMap {
|
||||
case relation ~ followable ~ blocked =>
|
||||
(ctx.userId ?? { api.fetchBlocks(userId, _) }) flatMap { case relation ~ followable ~ blocked =>
|
||||
negotiate(
|
||||
html = fuccess(Ok {
|
||||
if (mini)
|
||||
|
|
|
@ -119,11 +119,10 @@ final class Relay(
|
|||
OpenOrScoped(_.Study.Read)(
|
||||
open = implicit ctx => {
|
||||
pageHit
|
||||
WithRelay(slug, id) {
|
||||
relay =>
|
||||
WithRelay(slug, id) { relay =>
|
||||
val sc =
|
||||
if (relay.sync.ongoing) env.study.chapterRepo relaysAndTagsByStudyId relay.studyId flatMap {
|
||||
chapters =>
|
||||
if (relay.sync.ongoing)
|
||||
env.study.chapterRepo relaysAndTagsByStudyId relay.studyId flatMap { chapters =>
|
||||
chapters.find(_.looksAlive) orElse chapters.headOption match {
|
||||
case Some(chapter) => env.study.api.byIdWithChapter(relay.studyId, chapter.id)
|
||||
case None => env.study.api byIdWithChapter relay.studyId
|
||||
|
|
|
@ -35,16 +35,14 @@ final class Report(
|
|||
|
||||
private def renderList(room: String)(implicit ctx: Context) =
|
||||
api.openAndRecentWithFilter(12, Room(room)) zip
|
||||
getCounts flatMap {
|
||||
case (reports, counts ~ streamers ~ appeals) =>
|
||||
getCounts flatMap { case (reports, counts ~ streamers ~ appeals) =>
|
||||
(env.user.lightUserApi preloadMany reports.flatMap(_.report.userIds)) inject
|
||||
Ok(html.report.list(reports, room, counts, streamers, appeals))
|
||||
}
|
||||
|
||||
def inquiry(id: String) =
|
||||
Secure(_.SeeReport) { _ => me =>
|
||||
api.inquiries.toggle(AsMod(me), id) map {
|
||||
case (prev, next) =>
|
||||
api.inquiries.toggle(AsMod(me), id) map { case (prev, next) =>
|
||||
next.fold(
|
||||
Redirect {
|
||||
if (prev.exists(_.isAppeal)) routes.Appeal.queue()
|
||||
|
@ -95,8 +93,7 @@ final class Report(
|
|||
}
|
||||
else if (force) userC.modZoneOrRedirect(prev.user)
|
||||
else
|
||||
api.inquiries.toggle(AsMod(me), prev.id) map {
|
||||
case (prev, next) =>
|
||||
api.inquiries.toggle(AsMod(me), prev.id) map { case (prev, next) =>
|
||||
next.fold(
|
||||
if (prev.exists(_.isAppeal)) Redirect(routes.Appeal.queue())
|
||||
else redirectToList
|
||||
|
@ -133,8 +130,8 @@ final class Report(
|
|||
def form =
|
||||
Auth { implicit ctx => _ =>
|
||||
get("username") ?? env.user.repo.named flatMap { user =>
|
||||
env.report.forms.createWithCaptcha map {
|
||||
case (form, captcha) => Ok(html.report.form(form, user, captcha))
|
||||
env.report.forms.createWithCaptcha map { case (form, captcha) =>
|
||||
Ok(html.report.form(form, user, captcha))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,8 +33,7 @@ final class Round(
|
|||
else
|
||||
PreventTheft(pov) {
|
||||
pov.game.playableByAi ?? env.fishnet.player(pov.game)
|
||||
env.tournament.api.gameView.player(pov) flatMap {
|
||||
tour =>
|
||||
env.tournament.api.gameView.player(pov) flatMap { tour =>
|
||||
gameC.preloadUsers(pov.game) zip
|
||||
(pov.game.simulId ?? env.simul.repo.find) zip
|
||||
getPlayerChat(pov.game, tour.map(_.tour)) zip
|
||||
|
@ -67,8 +66,7 @@ final class Round(
|
|||
pov.game.playableByAi ?? env.fishnet.player(pov.game)
|
||||
gameC.preloadUsers(pov.game) zip
|
||||
env.api.roundApi.player(pov, tour, apiVersion) zip
|
||||
getPlayerChat(pov.game, none) map {
|
||||
case _ ~ data ~ chat =>
|
||||
getPlayerChat(pov.game, none) map { case _ ~ data ~ chat =>
|
||||
Ok {
|
||||
data.add("chat", chat.flatMap(_.game).map(c => lila.chat.JsonView(c.chat)))
|
||||
}
|
||||
|
@ -243,7 +241,8 @@ final class Round(
|
|||
)
|
||||
.some
|
||||
(game.tournamentId, game.simulId, game.swissId) match {
|
||||
case (Some(tid), _, _) => {
|
||||
case (Some(tid), _, _) =>
|
||||
{
|
||||
ctx.isAuth && tour.fold(true)(tournamentC.canHaveChat(_, none))
|
||||
} ?? env.chat.api.userChat.cached
|
||||
.findMine(Chat.Id(tid), ctx.me)
|
||||
|
|
|
@ -18,15 +18,13 @@ final class Simul(env: Env) extends LilaController(env) {
|
|||
|
||||
val home = Open { implicit ctx =>
|
||||
pageHit
|
||||
fetchSimuls(ctx.me) flatMap {
|
||||
case pending ~ created ~ started ~ finished =>
|
||||
fetchSimuls(ctx.me) flatMap { case pending ~ created ~ started ~ finished =>
|
||||
Ok(html.simul.home(pending, created, started, finished)).fuccess
|
||||
}
|
||||
}
|
||||
|
||||
val apiList = Action.async {
|
||||
fetchSimuls(none) flatMap {
|
||||
case pending ~ created ~ started ~ finished =>
|
||||
fetchSimuls(none) flatMap { case pending ~ created ~ started ~ finished =>
|
||||
env.simul.jsonView.apiAll(pending, created, started, finished) map { json =>
|
||||
Ok(json) as JSON
|
||||
}
|
||||
|
@ -34,8 +32,7 @@ final class Simul(env: Env) extends LilaController(env) {
|
|||
}
|
||||
|
||||
val homeReload = Open { implicit ctx =>
|
||||
fetchSimuls(ctx.me) map {
|
||||
case pending ~ created ~ started ~ finished =>
|
||||
fetchSimuls(ctx.me) map { case pending ~ created ~ started ~ finished =>
|
||||
Ok(html.simul.homeInner(pending, created, started, finished))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,8 +136,8 @@ final class Streamer(
|
|||
AsStreamer { s =>
|
||||
ctx.body.body.file("picture") match {
|
||||
case Some(pic) =>
|
||||
api.uploadPicture(s.streamer, pic) recover {
|
||||
case e: lila.base.LilaException => BadRequest(html.streamer.picture(s, e.message.some))
|
||||
api.uploadPicture(s.streamer, pic) recover { case e: lila.base.LilaException =>
|
||||
BadRequest(html.streamer.picture(s, e.message.some))
|
||||
} inject Redirect(routes.Streamer.edit())
|
||||
case None => fuccess(Redirect(routes.Streamer.edit()))
|
||||
}
|
||||
|
|
|
@ -79,8 +79,7 @@ final class Study(
|
|||
Auth { implicit ctx => me =>
|
||||
env.study.pager.mine(me, Order(order), page) flatMap { pag =>
|
||||
negotiate(
|
||||
html =
|
||||
env.study.topicApi.userTopics(me.id) map { topics =>
|
||||
html = env.study.topicApi.userTopics(me.id) map { topics =>
|
||||
Ok(html.study.list.mine(pag, Order(order), me, topics))
|
||||
},
|
||||
api = _ => apiStudies(pag)
|
||||
|
@ -112,8 +111,7 @@ final class Study(
|
|||
Auth { implicit ctx => me =>
|
||||
env.study.pager.mineMember(me, Order(order), page) flatMap { pag =>
|
||||
negotiate(
|
||||
html =
|
||||
env.study.topicApi.userTopics(me.id) map { topics =>
|
||||
html = env.study.topicApi.userTopics(me.id) map { topics =>
|
||||
Ok(html.study.list.mineMember(pag, Order(order), me, topics))
|
||||
},
|
||||
api = _ => apiStudies(pag)
|
||||
|
@ -137,8 +135,7 @@ final class Study(
|
|||
case None => notFound
|
||||
case Some(topic) =>
|
||||
env.study.pager.byTopic(topic, ctx.me, Order(order), page) zip
|
||||
ctx.me.??(u => env.study.topicApi.userTopics(u.id) dmap some) map {
|
||||
case (pag, topics) =>
|
||||
ctx.me.??(u => env.study.topicApi.userTopics(u.id) dmap some) map { case (pag, topics) =>
|
||||
Ok(html.study.topic.show(topic, pag, Order(order), topics))
|
||||
}
|
||||
}
|
||||
|
@ -341,8 +338,7 @@ final class Study(
|
|||
def embed(id: String, chapterId: String) =
|
||||
Action.async { implicit req =>
|
||||
env.study.api.byIdWithChapter(id, chapterId).map(_.filterNot(_.study.isPrivate)) flatMap {
|
||||
_.fold(embedNotFound) {
|
||||
case WithChapter(study, chapter) =>
|
||||
_.fold(embedNotFound) { case WithChapter(study, chapter) =>
|
||||
for {
|
||||
chapters <- env.study.chapterRepo.idNames(study.id)
|
||||
studyJson <- env.study.jsonView(
|
||||
|
@ -446,8 +442,7 @@ final class Study(
|
|||
def chapterPgn(id: String, chapterId: String) =
|
||||
Open { implicit ctx =>
|
||||
env.study.api.byIdWithChapter(id, chapterId) flatMap {
|
||||
_.fold(notFound) {
|
||||
case WithChapter(study, chapter) =>
|
||||
_.fold(notFound) { case WithChapter(study, chapter) =>
|
||||
CanViewResult(study) {
|
||||
lila.mon.export.pgn.studyChapter.increment()
|
||||
Ok(env.study.pgnDump.ofChapter(study, requestPgnFlags(ctx.req))(chapter).toString)
|
||||
|
@ -471,8 +466,7 @@ final class Study(
|
|||
def chapterGif(id: String, chapterId: String) =
|
||||
Open { implicit ctx =>
|
||||
env.study.api.byIdWithChapter(id, chapterId) flatMap {
|
||||
_.fold(notFound) {
|
||||
case WithChapter(study, chapter) =>
|
||||
_.fold(notFound) { case WithChapter(study, chapter) =>
|
||||
CanViewResult(study) {
|
||||
env.study.gifExport.ofChapter(chapter) map { stream =>
|
||||
Ok.chunked(stream)
|
||||
|
@ -512,8 +506,7 @@ final class Study(
|
|||
def topics =
|
||||
Open { implicit ctx =>
|
||||
env.study.topicApi.popular(50) zip
|
||||
ctx.me.??(u => env.study.topicApi.userTopics(u.id) dmap some) map {
|
||||
case (popular, mine) =>
|
||||
ctx.me.??(u => env.study.topicApi.userTopics(u.id) dmap some) map { case (popular, mine) =>
|
||||
val form = mine map lila.study.StudyForm.topicsForm
|
||||
Ok(html.study.topic.index(popular, mine, form))
|
||||
}
|
||||
|
|
|
@ -331,15 +331,13 @@ final class Team(
|
|||
OptionFuRedirectUrl(for {
|
||||
requestOption <- api request requestId
|
||||
teamOption <- requestOption.??(req => env.team.teamRepo.byLeader(req.team, me.id))
|
||||
} yield (teamOption, requestOption).mapN((_, _))) {
|
||||
case (team, request) =>
|
||||
} yield (teamOption, requestOption).mapN((_, _))) { case (team, request) =>
|
||||
implicit val req = ctx.body
|
||||
forms.processRequest
|
||||
.bindFromRequest()
|
||||
.fold(
|
||||
_ => fuccess(routes.Team.show(team.id).toString),
|
||||
{
|
||||
case (decision, url) =>
|
||||
{ case (decision, url) =>
|
||||
api.processRequest(team, request, decision == "accept") inject url
|
||||
}
|
||||
)
|
||||
|
|
|
@ -410,8 +410,7 @@ final class Tournament(
|
|||
|
||||
def categShields(k: String) =
|
||||
Open { implicit ctx =>
|
||||
OptionFuOk(env.tournament.shieldApi.byCategKey(k)) {
|
||||
case (categ, awards) =>
|
||||
OptionFuOk(env.tournament.shieldApi.byCategKey(k)) { case (categ, awards) =>
|
||||
env.user.lightUserApi preloadMany awards.map(_.owner.value) inject
|
||||
html.tournament.shields.byCateg(categ, awards)
|
||||
}
|
||||
|
|
|
@ -39,8 +39,7 @@ final class Tv(
|
|||
}
|
||||
|
||||
private def lichessTv(channel: lila.tv.Tv.Channel)(implicit ctx: Context) =
|
||||
OptionFuResult(env.tv.tv getGameAndHistory channel) {
|
||||
case (game, history) =>
|
||||
OptionFuResult(env.tv.tv getGameAndHistory channel) { case (game, history) =>
|
||||
val flip = getBool("flip")
|
||||
val natural = Pov naturalOrientation game
|
||||
val pov = if (flip) !natural else natural
|
||||
|
@ -49,8 +48,7 @@ final class Tv(
|
|||
html = env.tournament.api.gameView.watcher(pov.game) flatMap { tour =>
|
||||
env.api.roundApi.watcher(pov, tour, lila.api.Mobile.Api.currentVersion, tv = onTv.some) zip
|
||||
env.game.crosstableApi.withMatchup(game) zip
|
||||
env.tv.tv.getChampions map {
|
||||
case data ~ cross ~ champions =>
|
||||
env.tv.tv.getChampions map { case data ~ cross ~ champions =>
|
||||
NoCache {
|
||||
Ok(html.tv.index(channel, champions, pov, data, cross, history))
|
||||
}
|
||||
|
@ -65,8 +63,7 @@ final class Tv(
|
|||
def gamesChannel(chanKey: String) =
|
||||
Open { implicit ctx =>
|
||||
(lila.tv.Tv.Channel.byKey get chanKey) ?? { channel =>
|
||||
env.tv.tv.getChampions zip env.tv.tv.getGames(channel, 15) map {
|
||||
case (champs, games) =>
|
||||
env.tv.tv.getChampions zip env.tv.tv.getGames(channel, 15) map { case (champs, games) =>
|
||||
NoCache {
|
||||
Ok(html.tv.games(channel, games map Pov.naturalOrientation, champs))
|
||||
}
|
||||
|
|
|
@ -461,8 +461,7 @@ final class User(
|
|||
relateds <-
|
||||
ops
|
||||
.zip(followables)
|
||||
.map {
|
||||
case ((u, nb), followable) =>
|
||||
.map { case ((u, nb), followable) =>
|
||||
relationApi.fetchRelation(me.id, u.id) map {
|
||||
lila.relation.Related(u, nb.some, followable, _)
|
||||
}
|
||||
|
@ -516,7 +515,8 @@ final class User(
|
|||
env.user.repo nameExists term map { r =>
|
||||
Ok(JsBoolean(r))
|
||||
}
|
||||
case Some(term) => {
|
||||
case Some(term) =>
|
||||
{
|
||||
(get("tour"), get("swiss")) match {
|
||||
case (Some(tourId), _) => env.tournament.playerRepo.searchPlayers(tourId, term, 10)
|
||||
case (_, Some(swissId)) => env.swiss.api.searchPlayers(lila.swiss.Swiss.Id(swissId), term, 10)
|
||||
|
|
|
@ -113,8 +113,7 @@ final class UserAnalysis(
|
|||
env.game.gameRepo initialFen pov.gameId flatMap { initialFen =>
|
||||
gameC.preloadUsers(pov.game) zip
|
||||
(env.analyse.analyser get pov.game) zip
|
||||
env.game.crosstableApi(pov.game) flatMap {
|
||||
case _ ~ analysis ~ crosstable =>
|
||||
env.game.crosstableApi(pov.game) flatMap { case _ ~ analysis ~ crosstable =>
|
||||
import lila.game.JsonView.crosstableWrites
|
||||
env.api.roundApi.review(
|
||||
pov,
|
||||
|
@ -142,8 +141,7 @@ final class UserAnalysis(
|
|||
.inMemory(data)
|
||||
.fold(
|
||||
err => BadRequest(jsonError(err)).fuccess,
|
||||
{
|
||||
case (game, fen) =>
|
||||
{ case (game, fen) =>
|
||||
val pov = Pov(game, chess.White)
|
||||
env.api.roundApi.userAnalysisJson(
|
||||
pov,
|
||||
|
@ -176,8 +174,8 @@ final class UserAnalysis(
|
|||
env.round.forecastApi.loadForDisplay(pov) map {
|
||||
case None => Ok(Json.obj("none" -> true))
|
||||
case Some(fc) => Ok(Json toJson fc) as JSON
|
||||
} recover {
|
||||
case Forecast.OutOfSync => Ok(Json.obj("reload" -> true))
|
||||
} recover { case Forecast.OutOfSync =>
|
||||
Ok(Json.obj("reload" -> true))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
|
|
@ -33,8 +33,7 @@ final class Video(env: Env) extends LilaController(env) {
|
|||
}
|
||||
case None =>
|
||||
api.video.byTags(ctx.me, control.filter.tags, getInt("page") | 1) zip
|
||||
api.video.count.apply map {
|
||||
case (videos, count) =>
|
||||
api.video.count.apply map { case (videos, count) =>
|
||||
Ok(html.video.index(videos, count, control))
|
||||
}
|
||||
}
|
||||
|
@ -50,8 +49,7 @@ final class Video(env: Env) extends LilaController(env) {
|
|||
api.video.similar(ctx.me, video, 9) zip
|
||||
ctx.userId.?? { userId =>
|
||||
api.view.add(View.make(videoId = video.id, userId = userId))
|
||||
} map {
|
||||
case (similar, _) =>
|
||||
} map { case (similar, _) =>
|
||||
Ok(html.video.show(video, similar, control))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,7 @@ final class ErrorHandler(
|
|||
)
|
||||
})
|
||||
else InternalServerError("Sorry, something went wrong.")
|
||||
} recover {
|
||||
case util.control.NonFatal(e) =>
|
||||
} recover { case util.control.NonFatal(e) =>
|
||||
lila.log("http").error(s"""Error handler exception on "${exception.getMessage}\"""", e)
|
||||
InternalServerError("Sorry, something went very wrong.")
|
||||
}
|
||||
|
|
|
@ -65,8 +65,7 @@ final class Preload(
|
|||
.preloadMany {
|
||||
tWinners.map(_.userId) ::: posts.flatMap(_.userId) ::: entries.flatMap(_.userIds).toList
|
||||
}
|
||||
.mon(_.lobby segment "lightUsers") map {
|
||||
case (currentGame, _) =>
|
||||
.mon(_.lobby segment "lightUsers") map { case (currentGame, _) =>
|
||||
Homepage(
|
||||
data,
|
||||
entries,
|
||||
|
|
|
@ -76,8 +76,7 @@ object UserInfo {
|
|||
} zip
|
||||
ctx.userId.?? { myId =>
|
||||
relationApi.fetchBlocks(u.id, myId).mon(_.user segment "blocks")
|
||||
} dmap {
|
||||
case relation ~ notes ~ followable ~ blocked =>
|
||||
} dmap { case relation ~ notes ~ followable ~ blocked =>
|
||||
Social(relation, notes, followable, blocked)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,7 @@ trait ChessgroundHelper {
|
|||
val pieces =
|
||||
if (ctx.pref.isBlindfold) ""
|
||||
else
|
||||
board.pieces.map {
|
||||
case (pos, piece) =>
|
||||
board.pieces.map { case (pos, piece) =>
|
||||
val klass = s"${piece.color.name} ${piece.role.name}"
|
||||
s"""<piece class="$klass" style="top:${top(pos)}%;left:${left(pos)}%"></piece>"""
|
||||
} mkString ""
|
||||
|
@ -44,8 +43,8 @@ trait ChessgroundHelper {
|
|||
chessground(
|
||||
board = pov.game.board,
|
||||
orient = pov.color,
|
||||
lastMove = pov.game.history.lastMove.map(_.origDest) ?? {
|
||||
case (orig, dest) => List(orig, dest)
|
||||
lastMove = pov.game.history.lastMove.map(_.origDest) ?? { case (orig, dest) =>
|
||||
List(orig, dest)
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -140,8 +140,7 @@ trait FormHelper { self: I18nHelper =>
|
|||
cls := "form-control"
|
||||
)(disabled option (st.disabled := true))(validationModifiers(field))(
|
||||
default map { option(value := "")(_) },
|
||||
options.toSeq map {
|
||||
case (value, name) =>
|
||||
options.toSeq map { case (value, name) =>
|
||||
option(
|
||||
st.value := value.toString,
|
||||
field.value.has(value.toString) option selected
|
||||
|
|
|
@ -180,7 +180,8 @@ trait GameHelper { self: I18nHelper with UserHelper with AiHelper with StringHel
|
|||
case None => trans.draw.txt()
|
||||
}
|
||||
case S.Draw => trans.draw.txt()
|
||||
case S.Outoftime => (game.turnColor, game.loser) match {
|
||||
case S.Outoftime =>
|
||||
(game.turnColor, game.loser) match {
|
||||
case (White, Some(_)) => trans.whiteTimeOut.txt()
|
||||
case (White, None) => trans.whiteTimeOut.txt() + " • " + trans.draw.txt()
|
||||
case (Black, Some(_)) => trans.blackTimeOut.txt()
|
||||
|
|
|
@ -57,8 +57,8 @@ trait TournamentHelper { self: I18nHelper with DateHelper with UserHelper =>
|
|||
|
||||
def apply(name: String): Frag =
|
||||
raw {
|
||||
replacements.foldLeft(name) {
|
||||
case (n, (from, to)) => n.replace(from, to)
|
||||
replacements.foldLeft(name) { case (n, (from, to)) =>
|
||||
n.replace(from, to)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -55,12 +55,12 @@ trait UserHelper { self: I18nHelper with StringHelper with NumberHelper =>
|
|||
PerfType(perfKey) map { showPerfRating(u, _) }
|
||||
|
||||
def showBestPerf(u: User)(implicit lang: Lang): Option[Frag] =
|
||||
u.perfs.bestPerf map {
|
||||
case (pt, perf) => showPerfRating(pt, perf)
|
||||
u.perfs.bestPerf map { case (pt, perf) =>
|
||||
showPerfRating(pt, perf)
|
||||
}
|
||||
def showBestPerfs(u: User, nb: Int)(implicit lang: Lang): List[Frag] =
|
||||
u.perfs.bestPerfs(nb) map {
|
||||
case (pt, perf) => showPerfRating(pt, perf)
|
||||
u.perfs.bestPerfs(nb) map { case (pt, perf) =>
|
||||
showPerfRating(pt, perf)
|
||||
}
|
||||
|
||||
def showRatingDiff(diff: Int): Frag =
|
||||
|
@ -219,8 +219,8 @@ trait UserHelper { self: I18nHelper with StringHelper with NumberHelper =>
|
|||
withPerfRating match {
|
||||
case Some(perfType) => renderRating(user.perfs(perfType))
|
||||
case _ if withBestRating =>
|
||||
user.perfs.bestPerf ?? {
|
||||
case (_, perf) => renderRating(perf)
|
||||
user.perfs.bestPerf ?? { case (_, perf) =>
|
||||
renderRating(perf)
|
||||
}
|
||||
case _ => ""
|
||||
}
|
||||
|
@ -266,8 +266,8 @@ trait UserHelper { self: I18nHelper with StringHelper with NumberHelper =>
|
|||
val name = user.titleUsername
|
||||
val nbGames = user.count.game
|
||||
val createdAt = org.joda.time.format.DateTimeFormat forStyle "M-" print user.createdAt
|
||||
val currentRating = user.perfs.bestPerf ?? {
|
||||
case (pt, perf) => s" Current ${pt.trans} rating: ${perf.intRating}."
|
||||
val currentRating = user.perfs.bestPerf ?? { case (pt, perf) =>
|
||||
s" Current ${pt.trans} rating: ${perf.intRating}."
|
||||
}
|
||||
s"$name played $nbGames games since $createdAt.$currentRating"
|
||||
}
|
||||
|
|
|
@ -22,11 +22,11 @@ object activity {
|
|||
a.puzzles map renderPuzzles,
|
||||
a.games map renderGames,
|
||||
a.posts map renderPosts,
|
||||
a.corresMoves map {
|
||||
case (nb, povs) => renderCorresMoves(nb, povs)
|
||||
a.corresMoves map { case (nb, povs) =>
|
||||
renderCorresMoves(nb, povs)
|
||||
},
|
||||
a.corresEnds map {
|
||||
case (score, povs) => renderCorresEnds(score, povs)
|
||||
a.corresEnds map { case (score, povs) =>
|
||||
renderCorresEnds(score, povs)
|
||||
},
|
||||
a.follows map renderFollows,
|
||||
a.simuls map renderSimuls(u),
|
||||
|
@ -85,8 +85,7 @@ object activity {
|
|||
)
|
||||
|
||||
private def renderGames(games: Games)(implicit ctx: Context) =
|
||||
games.value.toSeq.sortBy(-_._2.size).map {
|
||||
case (pt, score) =>
|
||||
games.value.toSeq.sortBy(-_._2.size).map { case (pt, score) =>
|
||||
entryTag(
|
||||
iconTag(pt.iconChar),
|
||||
scoreFrag(score),
|
||||
|
@ -101,8 +100,7 @@ object activity {
|
|||
ctx.noKid option entryTag(
|
||||
iconTag("d"),
|
||||
div(
|
||||
posts.toSeq.map {
|
||||
case (topic, posts) =>
|
||||
posts.toSeq.map { case (topic, posts) =>
|
||||
val url = routes.ForumTopic.show(topic.categId, topic.slug)
|
||||
frag(
|
||||
trans.activity.postedNbMessages
|
||||
|
@ -167,8 +165,7 @@ object activity {
|
|||
entryTag(
|
||||
iconTag("h"),
|
||||
div(
|
||||
List(all.in.map(_ -> true), all.out.map(_ -> false)).flatten map {
|
||||
case (f, in) =>
|
||||
List(all.in.map(_ -> true), all.out.map(_ -> false)).flatten map { case (f, in) =>
|
||||
frag(
|
||||
if (in) trans.activity.gainedNbFollowers.pluralSame(f.actualNb)
|
||||
else trans.activity.followedNbPlayers.pluralSame(f.actualNb),
|
||||
|
@ -187,8 +184,7 @@ object activity {
|
|||
entryTag(
|
||||
iconTag("f"),
|
||||
div(
|
||||
simuls.groupBy(_.isHost(u.some)).toSeq.map {
|
||||
case (isHost, simuls) =>
|
||||
simuls.groupBy(_.isHost(u.some)).toSeq.map { case (isHost, simuls) =>
|
||||
frag(
|
||||
if (isHost) trans.activity.hostedNbSimuls.pluralSame(simuls.size)
|
||||
else trans.activity.joinedNbSimuls.pluralSame(simuls.size),
|
||||
|
|
|
@ -236,8 +236,7 @@ object appeal {
|
|||
div(
|
||||
select(cls := "appeal-presets")(
|
||||
option(st.value := "")("Presets"),
|
||||
ps.value.map {
|
||||
case ModPreset(name, text) =>
|
||||
ps.value.map { case ModPreset(name, text) =>
|
||||
option(
|
||||
st.value := text,
|
||||
st.title := text
|
||||
|
|
|
@ -48,8 +48,8 @@ object signup {
|
|||
"You must agree to the Lichess policies listed below:"
|
||||
)
|
||||
),
|
||||
agreements.map {
|
||||
case (field, i18n) => form3.checkbox(form(field), i18n())
|
||||
agreements.map { case (field, i18n) =>
|
||||
form3.checkbox(form(field), i18n())
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -124,8 +124,7 @@ object student {
|
|||
s" ($nbStudents/${lila.clas.Clas.maxStudents})"
|
||||
),
|
||||
nbStudents > (lila.clas.Clas.maxStudents / 2) option maxStudentsWarning(clas),
|
||||
created map {
|
||||
case Student.WithPassword(student, password) =>
|
||||
created map { case Student.WithPassword(student, password) =>
|
||||
flashMessage(cls := "student-add__created")(
|
||||
strong(
|
||||
trans.clas.lichessProfileXCreatedForY(
|
||||
|
@ -222,8 +221,7 @@ object student {
|
|||
)
|
||||
),
|
||||
tbody(
|
||||
created map {
|
||||
case Student.WithPassword(student, password) =>
|
||||
created map { case Student.WithPassword(student, password) =>
|
||||
tr(
|
||||
td(student.realName),
|
||||
td(usernameOrId(student.userId)),
|
||||
|
|
|
@ -76,8 +76,7 @@ object studentDashboard {
|
|||
)
|
||||
),
|
||||
tbody(
|
||||
students.sortBy(-_.user.seenAt.??(_.getMillis)).map {
|
||||
case Student.WithUser(student, user) =>
|
||||
students.sortBy(-_.user.seenAt.??(_.getMillis)).map { case Student.WithUser(student, user) =>
|
||||
tr(
|
||||
td(
|
||||
userLink(
|
||||
|
|
|
@ -150,8 +150,7 @@ object teacherDashboard {
|
|||
)
|
||||
),
|
||||
tbody(
|
||||
students.sortBy(_.user.username).map {
|
||||
case s @ Student.WithUser(_, user) =>
|
||||
students.sortBy(_.user.username).map { case s @ Student.WithUser(_, user) =>
|
||||
val prog = progress(user)
|
||||
tr(
|
||||
studentTd(c, s),
|
||||
|
@ -193,8 +192,7 @@ object teacherDashboard {
|
|||
)
|
||||
),
|
||||
tbody(
|
||||
students.sortBy(_.user.username).map {
|
||||
case s @ Student.WithUser(_, user) =>
|
||||
students.sortBy(_.user.username).map { case s @ Student.WithUser(_, user) =>
|
||||
val coord = coordScores.getOrElse(user.id, chess.Color.Map(0, 0))
|
||||
tr(
|
||||
studentTd(c, s),
|
||||
|
@ -270,8 +268,7 @@ object teacherDashboard {
|
|||
)
|
||||
),
|
||||
tbody(
|
||||
students.sortBy(_.user.username).map {
|
||||
case s @ Student.WithUser(student, user) =>
|
||||
students.sortBy(_.user.username).map { case s @ Student.WithUser(student, user) =>
|
||||
tr(
|
||||
studentTd(c, s),
|
||||
td(dataSort := user.perfs.bestRating, cls := "rating")(user.best3Perfs.map {
|
||||
|
|
|
@ -50,8 +50,7 @@ object index {
|
|||
"coach-lang",
|
||||
lang.fold("All languages")(LangList.name),
|
||||
langSelections
|
||||
.map {
|
||||
case (code, name) =>
|
||||
.map { case (code, name) =>
|
||||
a(
|
||||
href := routes.Coach.search(code, order.key),
|
||||
cls := (code == lang.fold("all")(_.code)).option("current")
|
||||
|
|
|
@ -95,8 +95,7 @@ object coordinate {
|
|||
List(
|
||||
(trans.coordinates.averageScoreAsWhiteX, score.white),
|
||||
(trans.coordinates.averageScoreAsBlackX, score.black)
|
||||
).map {
|
||||
case (averageScoreX, s) =>
|
||||
).map { case (averageScoreX, s) =>
|
||||
div(cls := "chart_container")(
|
||||
s.nonEmpty option frag(
|
||||
p(averageScoreX(raw(s"""<strong>${"%.2f".format(s.sum.toDouble / s.size)}</strong>"""))),
|
||||
|
|
|
@ -135,8 +135,7 @@ object categ {
|
|||
td(cls := "right")(categ.nbTopics.localize),
|
||||
td(cls := "right")(categ.nbPosts.localize),
|
||||
td(
|
||||
categ.lastPost.map {
|
||||
case (topic, post, page) =>
|
||||
categ.lastPost.map { case (topic, post, page) =>
|
||||
frag(
|
||||
a(href := s"${routes.ForumTopic.show(categ.slug, topic.slug, page)}#${post.number}")(
|
||||
momentFromNow(post.createdAt)
|
||||
|
|
|
@ -165,8 +165,7 @@ object topic {
|
|||
)
|
||||
)
|
||||
),
|
||||
formWithCaptcha.map {
|
||||
case (form, captcha) =>
|
||||
formWithCaptcha.map { case (form, captcha) =>
|
||||
postForm(
|
||||
cls := "form3 reply",
|
||||
action := s"${routes.ForumPost.create(categ.slug, topic.slug, posts.currentPage)}#reply",
|
||||
|
|
|
@ -21,8 +21,7 @@ object crosstable {
|
|||
}
|
||||
div(cls := "crosstable")(
|
||||
ct.fillSize > 0 option raw { s"""<fill style="flex:${ct.fillSize * 0.75} 1 auto"></fill>""" },
|
||||
ct.results.zipWithIndex.map {
|
||||
case (r, i) =>
|
||||
ct.results.zipWithIndex.map { case (r, i) =>
|
||||
tag("povs")(
|
||||
cls := List(
|
||||
"sep" -> matchupSepAt.has(i),
|
||||
|
|
|
@ -143,8 +143,7 @@ object widgets {
|
|||
aiRating(level)
|
||||
)
|
||||
} getOrElse {
|
||||
(player.nameSplit.fold[Frag](anonSpan) {
|
||||
case (name, rating) =>
|
||||
(player.nameSplit.fold[Frag](anonSpan) { case (name, rating) =>
|
||||
frag(
|
||||
span(name),
|
||||
rating.map { r =>
|
||||
|
|
|
@ -103,8 +103,7 @@ object communication {
|
|||
priv option frag(
|
||||
h2("Recent private chats"),
|
||||
div(cls := "player_chats")(
|
||||
players.map {
|
||||
case (pov, chat) =>
|
||||
players.map { case (pov, chat) =>
|
||||
div(cls := "game")(
|
||||
a(
|
||||
href := routes.Round.player(pov.fullId),
|
||||
|
|
|
@ -87,8 +87,7 @@ object gamify {
|
|||
)
|
||||
),
|
||||
tbody(
|
||||
leaderboards(period).zipWithIndex.map {
|
||||
case (m, i) =>
|
||||
leaderboards(period).zipWithIndex.map { case (m, i) =>
|
||||
tr(
|
||||
th(i + 1),
|
||||
th(userIdLink(m.modId.some, withOnline = false)),
|
||||
|
|
|
@ -27,8 +27,7 @@ object permissions {
|
|||
div(cls := "permission-list")(
|
||||
lila.security.Permission.categorized
|
||||
.filter { case (_, ps) => ps.exists(canGrant(me, _)) }
|
||||
.map {
|
||||
case (categ, perms) =>
|
||||
.map { case (categ, perms) =>
|
||||
st.section(
|
||||
h2(categ),
|
||||
perms
|
||||
|
|
|
@ -24,8 +24,7 @@ object publicChat {
|
|||
div(id := "communication", cls := "page-menu__content public_chat box box-pad")(
|
||||
h2("Tournament Chats"),
|
||||
div(cls := "player_chats")(
|
||||
tourChats.map {
|
||||
case (tournament, chat) =>
|
||||
tourChats.map { case (tournament, chat) =>
|
||||
div(cls := "game")(
|
||||
a(cls := "title", href := routes.Tournament.show(tournament.id))(tournament.name),
|
||||
div(cls := "chat")(
|
||||
|
@ -43,8 +42,7 @@ object publicChat {
|
|||
div(
|
||||
h2("Simul Chats"),
|
||||
div(cls := "player_chats")(
|
||||
simulChats.map {
|
||||
case (simul, chat) =>
|
||||
simulChats.map { case (simul, chat) =>
|
||||
div(cls := "game")(
|
||||
a(cls := "title", href := routes.Simul.show(simul.id))(simul.name),
|
||||
div(cls := "chat")(
|
||||
|
|
|
@ -125,8 +125,7 @@ object search {
|
|||
)
|
||||
),
|
||||
tbody(
|
||||
users.map {
|
||||
case lila.user.User.WithEmails(u, emails) =>
|
||||
users.map { case lila.user.User.WithEmails(u, emails) =>
|
||||
tr(
|
||||
td(
|
||||
userLink(u, withBestRating = true, params = "?mod"),
|
||||
|
|
|
@ -100,8 +100,7 @@ object bits {
|
|||
}
|
||||
),
|
||||
div(cls := "now-playing")(
|
||||
playing.partition(_.isMyTurn) pipe {
|
||||
case (myTurn, otherTurn) =>
|
||||
playing.partition(_.isMyTurn) pipe { case (myTurn, otherTurn) =>
|
||||
(myTurn ++ otherTurn.take(6 - myTurn.size)) take 9 map {
|
||||
views.html.game.mini(_)
|
||||
}
|
||||
|
|
|
@ -41,8 +41,8 @@ private object bits {
|
|||
renderLabel(form("variant"), trans.variant()),
|
||||
renderSelect(
|
||||
form("variant"),
|
||||
variants.filter {
|
||||
case (id, _, _) => ctx.noBlind || lila.game.Game.blindModeVariants.exists(_.id.toString == id)
|
||||
variants.filter { case (id, _, _) =>
|
||||
ctx.noBlind || lila.game.Game.blindModeVariants.exists(_.id.toString == id)
|
||||
}
|
||||
)
|
||||
)
|
||||
|
@ -53,8 +53,7 @@ private object bits {
|
|||
compare: (String, String) => Boolean = (a, b) => a == b
|
||||
) =
|
||||
select(id := s"$prefix${field.id}", name := field.name)(
|
||||
options.map {
|
||||
case (value, name, title) =>
|
||||
options.map { case (value, name, title) =>
|
||||
option(
|
||||
st.value := value,
|
||||
st.title := title,
|
||||
|
@ -65,8 +64,7 @@ private object bits {
|
|||
|
||||
def renderRadios(field: Field, options: Seq[SelectChoice]) =
|
||||
st.group(cls := "radio")(
|
||||
options.map {
|
||||
case (key, name, hint) =>
|
||||
options.map { case (key, name, hint) =>
|
||||
div(
|
||||
input(
|
||||
tpe := "radio",
|
||||
|
|
|
@ -76,8 +76,7 @@ object filter {
|
|||
options: Seq[(Any, String, Option[String])],
|
||||
checks: Set[String] = Set.empty
|
||||
): Frag =
|
||||
options.zipWithIndex.map {
|
||||
case ((value, text, hint), index) =>
|
||||
options.zipWithIndex.map { case ((value, text, hint), index) =>
|
||||
div(cls := "checkable")(
|
||||
renderCheckbox(form, key, index, value.toString, raw(text), hint, checks)
|
||||
)
|
||||
|
|
|
@ -68,8 +68,7 @@ object forms {
|
|||
renderRadios(form("level"), lila.setup.AiConfig.levelChoices)
|
||||
),
|
||||
div(cls := "ai_info")(
|
||||
ratings.toList.map {
|
||||
case (level, _) =>
|
||||
ratings.toList.map { case (level, _) =>
|
||||
div(cls := s"${prefix}level_$level")(trans.aiNameLevelAiLevel("A.I.", level))
|
||||
}
|
||||
)
|
||||
|
@ -138,8 +137,7 @@ object forms {
|
|||
if (ctx.blind) submitButton("Create the game")
|
||||
else
|
||||
div(cls := "color-submits")(
|
||||
translatedSideChoices.map {
|
||||
case (key, name, _) =>
|
||||
translatedSideChoices.map { case (key, name, _) =>
|
||||
submitButton(
|
||||
(typ == "hook") option disabled,
|
||||
title := name,
|
||||
|
|
|
@ -158,8 +158,7 @@ object contact {
|
|||
"trolling" -> trolling(),
|
||||
"insults" -> insults(),
|
||||
"some other reason" -> otherReason()
|
||||
).map {
|
||||
case (reason, name) =>
|
||||
).map { case (reason, name) =>
|
||||
Leaf(
|
||||
reason,
|
||||
frag("Report a player for ", name),
|
||||
|
|
|
@ -89,8 +89,7 @@ object edit extends Context.ToLang {
|
|||
)
|
||||
)
|
||||
),
|
||||
modData.map {
|
||||
case (log, notes) =>
|
||||
modData.map { case (log, notes) =>
|
||||
div(cls := "mod_log status")(
|
||||
strong(cls := "text", dataIcon := "!")(
|
||||
"Moderation history",
|
||||
|
|
|
@ -73,8 +73,7 @@ object timeline {
|
|||
a(href := routes.Simul.show(simulId))(simulName)
|
||||
)
|
||||
case GameEnd(playerId, opponent, win, perfKey) =>
|
||||
lila.rating.PerfType(perfKey) map {
|
||||
perf =>
|
||||
lila.rating.PerfType(perfKey) map { perf =>
|
||||
(win match {
|
||||
case Some(true) => trans.victoryVsYInZ
|
||||
case Some(false) => trans.defeatVsYInZ
|
||||
|
|
|
@ -22,8 +22,7 @@ object shields {
|
|||
div(cls := "page-menu__content box box-pad")(
|
||||
h1("Tournament shields"),
|
||||
div(cls := "tournament-shields")(
|
||||
history.sorted.map {
|
||||
case (categ, awards) =>
|
||||
history.sorted.map { case (categ, awards) =>
|
||||
section(
|
||||
h2(
|
||||
a(href := routes.Tournament.categShields(categ.key))(
|
||||
|
|
|
@ -505,8 +505,7 @@ object mod {
|
|||
)
|
||||
),
|
||||
tbody(
|
||||
othersWithEmail.others.map {
|
||||
case other @ UserSpy.OtherUser(o, _, _) =>
|
||||
othersWithEmail.others.map { case other @ UserSpy.OtherUser(o, _, _) =>
|
||||
val dox = isGranted(_.Doxing) || (o.lameOrAlt && !o.hasTitle)
|
||||
val userNotes =
|
||||
notes.filter(n => n.to == o.id && (ctx.me.exists(n.isFrom) || isGranted(_.Doxing)))
|
||||
|
|
|
@ -29,8 +29,7 @@ object top {
|
|||
h1(a(href := routes.User.list(), dataIcon := "I"), title),
|
||||
table(cls := "slist slist-pad")(
|
||||
tbody(
|
||||
users.zipWithIndex.map {
|
||||
case (u, i) =>
|
||||
users.zipWithIndex.map { case (u, i) =>
|
||||
tr(
|
||||
td(i + 1),
|
||||
td(lightUserLink(u.user)),
|
||||
|
|
|
@ -38,8 +38,7 @@ object chart {
|
|||
)
|
||||
),
|
||||
tbody(
|
||||
data.perfResults.map {
|
||||
case (pt, res) =>
|
||||
data.perfResults.map { case (pt, res) =>
|
||||
tr(
|
||||
th(iconTag(pt.iconChar, pt.trans)),
|
||||
td(res.nb.localize),
|
||||
|
|
|
@ -55,8 +55,8 @@ final class ActivityReadApi(
|
|||
practice = (for {
|
||||
p <- a.practice
|
||||
struct <- practiceStructure
|
||||
} yield p.value flatMap {
|
||||
case (studyId, nb) => struct study studyId map (_ -> nb)
|
||||
} yield p.value flatMap { case (studyId, nb) =>
|
||||
struct study studyId map (_ -> nb)
|
||||
} toMap)
|
||||
postView = posts.map { p =>
|
||||
p.groupBy(_.topic)
|
||||
|
|
|
@ -22,8 +22,7 @@ private object BSONHandlers {
|
|||
implicit lazy val activityIdHandler = {
|
||||
val sep = ':'
|
||||
tryHandler[Id](
|
||||
{
|
||||
case BSONString(v) =>
|
||||
{ case BSONString(v) =>
|
||||
v split sep match {
|
||||
case Array(userId, dayStr) => Success(Id(userId, Day(Integer.parseInt(dayStr))))
|
||||
case _ => handlerBadValue(s"Invalid activity id $v")
|
||||
|
@ -35,8 +34,7 @@ private object BSONHandlers {
|
|||
|
||||
implicit private lazy val ratingHandler = BSONIntegerHandler.as[Rating](Rating.apply, _.value)
|
||||
implicit private lazy val ratingProgHandler = tryHandler[RatingProg](
|
||||
{
|
||||
case v: BSONArray =>
|
||||
{ case v: BSONArray =>
|
||||
for {
|
||||
before <- v.getAsTry[Rating](0)
|
||||
after <- v.getAsTry[Rating](1)
|
||||
|
|
|
@ -32,8 +32,8 @@ final class JsonView(
|
|||
implicit val scoreWrites = Json.writes[Score]
|
||||
implicit val gamesWrites = OWrites[Games] { games =>
|
||||
JsObject {
|
||||
games.value.toList.sortBy(-_._2.size).map {
|
||||
case (pt, score) => pt.key -> scoreWrites.writes(score)
|
||||
games.value.toList.sortBy(-_._2.size).map { case (pt, score) =>
|
||||
pt.key -> scoreWrites.writes(score)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -104,8 +104,7 @@ final class JsonView(
|
|||
.add("tournaments", a.tours)
|
||||
.add(
|
||||
"practice",
|
||||
a.practice.map(_.toList.sortBy(-_._2) map {
|
||||
case (study, nb) =>
|
||||
a.practice.map(_.toList.sortBy(-_._2) map { case (study, nb) =>
|
||||
Json.obj(
|
||||
"url" -> s"/practice/-/${study.slug}/${study.id}",
|
||||
"name" -> study.name,
|
||||
|
@ -116,21 +115,20 @@ final class JsonView(
|
|||
.add("simuls", a.simuls.map(_ map simulWrites(user).writes))
|
||||
.add(
|
||||
"correspondenceMoves",
|
||||
a.corresMoves.map {
|
||||
case (nb, povs) => Json.obj("nb" -> nb, "games" -> povs)
|
||||
a.corresMoves.map { case (nb, povs) =>
|
||||
Json.obj("nb" -> nb, "games" -> povs)
|
||||
}
|
||||
)
|
||||
.add(
|
||||
"correspondenceEnds",
|
||||
a.corresEnds.map {
|
||||
case (score, povs) => Json.obj("score" -> score, "games" -> povs)
|
||||
a.corresEnds.map { case (score, povs) =>
|
||||
Json.obj("score" -> score, "games" -> povs)
|
||||
}
|
||||
)
|
||||
.add("follows" -> a.follows)
|
||||
.add("studies" -> a.studies)
|
||||
.add("teams" -> a.teams)
|
||||
.add("posts" -> a.posts.map(_ map {
|
||||
case (topic, posts) =>
|
||||
.add("posts" -> a.posts.map(_ map { case (topic, posts) =>
|
||||
Json.obj(
|
||||
"topicUrl" -> s"/forum/${topic.categId}/${topic.slug}",
|
||||
"topicName" -> topic.name,
|
||||
|
|
|
@ -44,8 +44,7 @@ final class Analyser(
|
|||
analysis.studyId match {
|
||||
case None =>
|
||||
gameRepo gameWithInitialFen analysis.id map {
|
||||
_ ?? {
|
||||
case (game, initialFen) =>
|
||||
_ ?? { case (game, initialFen) =>
|
||||
Bus.publish(
|
||||
TellIfExists(
|
||||
analysis.id,
|
||||
|
|
|
@ -21,8 +21,7 @@ case class Analysis(
|
|||
def providedByLichess = by exists (_ startsWith "lichess-")
|
||||
|
||||
lazy val infoAdvices: InfoAdvices = {
|
||||
(Info.start(startPly) :: infos) sliding 2 collect {
|
||||
case List(prev, info) =>
|
||||
(Info.start(startPly) :: infos) sliding 2 collect { case List(prev, info) =>
|
||||
info -> {
|
||||
info.hasVariation ?? Advice(prev, info)
|
||||
}
|
||||
|
|
|
@ -21,8 +21,8 @@ final class AnalysisRepo(coll: Coll)(implicit ec: scala.concurrent.ExecutionCont
|
|||
|
||||
def associateToGames(games: List[Game]): Fu[List[Analysis.Analyzed]] =
|
||||
byIds(games.map(_.id)) map { as =>
|
||||
games zip as collect {
|
||||
case (game, Some(analysis)) => Analysis.Analyzed(game, analysis)
|
||||
games zip as collect { case (game, Some(analysis)) =>
|
||||
Analysis.Analyzed(game, analysis)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -33,8 +33,7 @@ final class Annotator(netDomain: lila.common.config.NetDomain) {
|
|||
}
|
||||
|
||||
private def annotateTurns(p: Pgn, advices: List[Advice]): Pgn =
|
||||
advices.foldLeft(p) {
|
||||
case (pgn, advice) =>
|
||||
advices.foldLeft(p) { case (pgn, advice) =>
|
||||
pgn.updateTurn(
|
||||
advice.turn,
|
||||
turn =>
|
||||
|
|
|
@ -80,8 +80,8 @@ object Info {
|
|||
}
|
||||
|
||||
def decodeList(str: String, fromPly: Int): Option[List[Info]] = {
|
||||
str.split(listSeparator).toList.zipWithIndex map {
|
||||
case (infoStr, index) => decode(index + 1 + fromPly, infoStr)
|
||||
str.split(listSeparator).toList.zipWithIndex map { case (infoStr, index) =>
|
||||
decode(index + 1 + fromPly, infoStr)
|
||||
}
|
||||
}.sequence
|
||||
|
||||
|
|
|
@ -8,8 +8,7 @@ import lila.tree.Eval.JsonHandlers._
|
|||
object JsonView {
|
||||
|
||||
def moves(analysis: Analysis, withGlyph: Boolean = true) =
|
||||
JsArray(analysis.infoAdvices map {
|
||||
case (info, adviceOption) =>
|
||||
JsArray(analysis.infoAdvices map { case (info, adviceOption) =>
|
||||
Json
|
||||
.obj()
|
||||
.add("eval" -> info.cp)
|
||||
|
@ -40,8 +39,8 @@ object JsonView {
|
|||
.find(_._1 == pov.color)
|
||||
.map(_._2)
|
||||
.map(s =>
|
||||
JsObject(s map {
|
||||
case (nag, nb) => nag.toString.toLowerCase -> JsNumber(nb)
|
||||
JsObject(s map { case (nag, nb) =>
|
||||
nag.toString.toLowerCase -> JsNumber(nb)
|
||||
}).add("acpl" -> lila.analyse.Accuracy.mean(pov, analysis))
|
||||
)
|
||||
|
||||
|
|
|
@ -65,8 +65,8 @@ final private[api] class Cli(
|
|||
|
||||
private def run(args: List[String]): Fu[String] = {
|
||||
(processors lift args) | fufail("Unknown command: " + args.mkString(" "))
|
||||
} recover {
|
||||
case e: Exception => "ERROR " + e
|
||||
} recover { case e: Exception =>
|
||||
"ERROR " + e
|
||||
}
|
||||
|
||||
private def processors =
|
||||
|
|
|
@ -90,8 +90,8 @@ final class Env(
|
|||
|
||||
private lazy val linkCheck = wire[LinkCheck]
|
||||
|
||||
Bus.subscribeFun("chatLinkCheck") {
|
||||
case GetLinkCheck(line, source, promise) => promise completeWith linkCheck(line, source)
|
||||
Bus.subscribeFun("chatLinkCheck") { case GetLinkCheck(line, source, promise) =>
|
||||
promise completeWith linkCheck(line, source)
|
||||
}
|
||||
|
||||
system.scheduler.scheduleWithFixedDelay(1 minute, 1 minute) { () =>
|
||||
|
|
|
@ -183,8 +183,7 @@ final private[api] class GameApi(
|
|||
else fuccess(List.fill(games.size)(none[Analysis]))
|
||||
allAnalysis flatMap { analysisOptions =>
|
||||
(games map gameRepo.initialFen).sequenceFu map { initialFens =>
|
||||
games zip analysisOptions zip initialFens map {
|
||||
case ((g, analysisOption), initialFen) =>
|
||||
games zip analysisOptions zip initialFens map { case ((g, analysisOption), initialFen) =>
|
||||
gameToJson(g, analysisOption, initialFen, checkToken(withFlags))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,8 +68,7 @@ final class GameApiV2(
|
|||
|
||||
private val fileR = """[\s,]""".r
|
||||
def filename(game: Game, format: Format): Fu[String] =
|
||||
gameLightUsers(game) map {
|
||||
case List(wu, bu) =>
|
||||
gameLightUsers(game) map { case List(wu, bu) =>
|
||||
fileR.replaceAllIn(
|
||||
"lichess_pgn_%s_%s_vs_%s.%s.%s".format(
|
||||
Tag.UTCDate.format.print(game.createdAt),
|
||||
|
@ -154,8 +153,7 @@ final class GameApiV2(
|
|||
playerRepo.teamsOfPlayers(config.tournamentId, pairings.flatMap(_.users).distinct).dmap(_.toMap)
|
||||
} flatMap { playerTeams =>
|
||||
gameRepo.gameOptionsFromSecondary(pairings.map(_.gameId)) map {
|
||||
_.zip(pairings) collect {
|
||||
case (Some(game), pairing) =>
|
||||
_.zip(pairings) collect { case (Some(game), pairing) =>
|
||||
import cats.implicits._
|
||||
(
|
||||
game,
|
||||
|
@ -172,11 +170,10 @@ final class GameApiV2(
|
|||
}
|
||||
}
|
||||
.mapConcat(identity)
|
||||
.mapAsync(4) {
|
||||
case (game, pairing, teams) => enrich(config.flags)(game) dmap { (_, pairing, teams) }
|
||||
.mapAsync(4) { case (game, pairing, teams) =>
|
||||
enrich(config.flags)(game) dmap { (_, pairing, teams) }
|
||||
}
|
||||
.mapAsync(4) {
|
||||
case ((game, fen, analysis), pairing, teams) =>
|
||||
.mapAsync(4) { case ((game, fen, analysis), pairing, teams) =>
|
||||
config.format match {
|
||||
case Format.PGN => pgnDump.formatter(config.flags)(game, fen, analysis, teams, none)
|
||||
case Format.JSON =>
|
||||
|
@ -207,8 +204,7 @@ final class GameApiV2(
|
|||
.mapAsync(1)(gameRepo.gamesFromSecondary)
|
||||
.mapConcat(identity)
|
||||
.mapAsync(4)(enrich(config.flags))
|
||||
.mapAsync(4) {
|
||||
case (game, fen, analysis) =>
|
||||
.mapAsync(4) { case (game, fen, analysis) =>
|
||||
config.format match {
|
||||
case Format.PGN => pgnDump.formatter(config.flags)(game, fen, analysis, none, none)
|
||||
case Format.JSON =>
|
||||
|
@ -221,8 +217,8 @@ final class GameApiV2(
|
|||
private def preparationFlow(config: Config, realPlayers: Option[RealPlayers]) =
|
||||
Flow[Game]
|
||||
.mapAsync(4)(enrich(config.flags))
|
||||
.mapAsync(4) {
|
||||
case (game, fen, analysis) => formatterFor(config)(game, fen, analysis, None, realPlayers)
|
||||
.mapAsync(4) { case (game, fen, analysis) =>
|
||||
formatterFor(config)(game, fen, analysis, None, realPlayers)
|
||||
}
|
||||
|
||||
private def enrich(flags: WithFlags)(game: Game) =
|
||||
|
@ -280,8 +276,7 @@ final class GameApiV2(
|
|||
"createdAt" -> g.createdAt,
|
||||
"lastMoveAt" -> g.movedAt,
|
||||
"status" -> g.status.name,
|
||||
"players" -> JsObject(g.players zip lightUsers map {
|
||||
case (p, user) =>
|
||||
"players" -> JsObject(g.players zip lightUsers map { case (p, user) =>
|
||||
p.color.name -> Json
|
||||
.obj()
|
||||
.add("user", user)
|
||||
|
|
|
@ -13,8 +13,7 @@ final class LobbyApi(
|
|||
|
||||
def apply(implicit ctx: Context): Fu[(JsObject, List[Pov])] =
|
||||
ctx.me.fold(seekApi.forAnon)(seekApi.forUser).mon(_.lobby segment "seeks") zip
|
||||
(ctx.me ?? gameProxyRepo.urgentGames).mon(_.lobby segment "urgentGames") flatMap {
|
||||
case (seeks, povs) =>
|
||||
(ctx.me ?? gameProxyRepo.urgentGames).mon(_.lobby segment "urgentGames") flatMap { case (seeks, povs) =>
|
||||
val displayedPovs = povs take 9
|
||||
lightUserApi.preloadMany(displayedPovs.flatMap(_.opponent.userId)) inject {
|
||||
implicit val lang = ctx.lang
|
||||
|
|
|
@ -81,8 +81,7 @@ final class PersonalDataExport(
|
|||
def privateMessages(msgs: Seq[(User.ID, String, DateTime)]) =
|
||||
List(
|
||||
textTitle(s"${msgs.size} Direct messages"),
|
||||
msgs.map {
|
||||
case (to, text, date) =>
|
||||
msgs.map { case (to, text, date) =>
|
||||
s"$to ${textDate(date)}\n$text"
|
||||
} mkString bigSep
|
||||
)
|
||||
|
|
|
@ -42,8 +42,7 @@ final class PgnDump(
|
|||
}
|
||||
|
||||
private def addEvals(p: Pgn, analysis: Analysis): Pgn =
|
||||
analysis.infos.foldLeft(p) {
|
||||
case (pgn, info) =>
|
||||
analysis.infos.foldLeft(p) { case (pgn, info) =>
|
||||
pgn.updateTurn(
|
||||
info.turn,
|
||||
turn =>
|
||||
|
|
|
@ -88,8 +88,7 @@ final private[api] class RoundApi(
|
|||
(pov.game.simulId ?? simulApi.find) zip
|
||||
swissApi.gameView(pov) zip
|
||||
(ctx.me.ifTrue(ctx.isMobileApi) ?? (me => noteApi.get(pov.gameId, me.id))) zip
|
||||
bookmarkApi.exists(pov.game, ctx.me) map {
|
||||
case json ~ simul ~ swiss ~ note ~ bookmarked =>
|
||||
bookmarkApi.exists(pov.game, ctx.me) map { case json ~ simul ~ swiss ~ note ~ bookmarked =>
|
||||
(
|
||||
withTournament(pov, tour) _ compose
|
||||
withSwiss(swiss) compose
|
||||
|
@ -127,8 +126,7 @@ final private[api] class RoundApi(
|
|||
(pov.game.simulId ?? simulApi.find) zip
|
||||
swissApi.gameView(pov) zip
|
||||
ctx.userId.ifTrue(ctx.isMobileApi).?? { noteApi.get(pov.gameId, _) } zip
|
||||
bookmarkApi.exists(pov.game, ctx.me) map {
|
||||
case json ~ tour ~ simul ~ swiss ~ note ~ bookmarked =>
|
||||
bookmarkApi.exists(pov.game, ctx.me) map { case json ~ tour ~ simul ~ swiss ~ note ~ bookmarked =>
|
||||
(
|
||||
withTournament(pov, tour) _ compose
|
||||
withSwiss(swiss) compose
|
||||
|
|
|
@ -33,7 +33,8 @@ final class ChallengeApi(
|
|||
def create(c: Challenge): Fu[Boolean] =
|
||||
isLimitedByMaxPlaying(c) flatMap {
|
||||
case true => fuFalse
|
||||
case false => {
|
||||
case false =>
|
||||
{
|
||||
repo like c flatMap { _ ?? repo.cancel }
|
||||
} >> (repo insert c) >>- {
|
||||
uncacheAndNotify(c)
|
||||
|
|
|
@ -57,8 +57,8 @@ final private class ChallengeRepo(coll: Coll, maxPerUser: Max)(implicit
|
|||
.void
|
||||
|
||||
private[challenge] def allWithUserId(userId: String): Fu[List[Challenge]] =
|
||||
createdByChallengerId(userId) zip createdByDestId(userId) dmap {
|
||||
case (x, y) => x ::: y
|
||||
createdByChallengerId(userId) zip createdByDestId(userId) dmap { case (x, y) =>
|
||||
x ::: y
|
||||
}
|
||||
|
||||
@nowarn("cat=unused") def like(c: Challenge) =
|
||||
|
@ -87,8 +87,7 @@ final private class ChallengeRepo(coll: Coll, maxPerUser: Max)(implicit
|
|||
.hint(coll hint $doc("seenAt" -> 1)) // partial index
|
||||
.cursor[Challenge]()
|
||||
.list(max)
|
||||
.recoverWith {
|
||||
case _: reactivemongo.core.errors.DatabaseException =>
|
||||
.recoverWith { case _: reactivemongo.core.errors.DatabaseException =>
|
||||
coll.list[Challenge](selector, max)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,8 @@ final private class ChallengeSocket(
|
|||
|
||||
private lazy val send: String => Unit = remoteSocketApi.makeSender("chal-out").apply _
|
||||
|
||||
private lazy val challengeHandler: Handler = {
|
||||
case Protocol.In.OwnerPings(ids) => ids foreach api.ping
|
||||
private lazy val challengeHandler: Handler = { case Protocol.In.OwnerPings(ids) =>
|
||||
ids foreach api.ping
|
||||
}
|
||||
|
||||
remoteSocketApi.subscribe("chal-in", Protocol.In.reader)(
|
||||
|
|
|
@ -65,8 +65,7 @@ private object Joiner {
|
|||
)
|
||||
.withId(c.id)
|
||||
.pipe { g =>
|
||||
state.fold(g) {
|
||||
case sit @ SituationPlus(Situation(board, _), _) =>
|
||||
state.fold(g) { case sit @ SituationPlus(Situation(board, _), _) =>
|
||||
g.copy(
|
||||
chess = g.chess.copy(
|
||||
situation = g.situation.copy(
|
||||
|
|
|
@ -19,8 +19,8 @@ final class JoinerTest extends Specification {
|
|||
destUser = None,
|
||||
rematchOf = None
|
||||
)
|
||||
Joiner.createGame(challenge, None, None, None) must beLike {
|
||||
case g: Game => g.chess.startedAtTurn must_== 0
|
||||
Joiner.createGame(challenge, None, None, None) must beLike { case g: Game =>
|
||||
g.chess.startedAtTurn must_== 0
|
||||
}
|
||||
}
|
||||
"started at turn from position" in {
|
||||
|
@ -35,8 +35,8 @@ final class JoinerTest extends Specification {
|
|||
destUser = None,
|
||||
rematchOf = None
|
||||
)
|
||||
Joiner.createGame(challenge, None, None, None) must beLike {
|
||||
case g: Game => g.chess.startedAtTurn must_== 6
|
||||
Joiner.createGame(challenge, None, None, None) must beLike { case g: Game =>
|
||||
g.chess.startedAtTurn must_== 6
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,8 +77,8 @@ case class MixedChat(
|
|||
def mapLines(f: Line => Line) = copy(lines = lines map f)
|
||||
|
||||
def userIds =
|
||||
lines.collect {
|
||||
case l: UserLine => l.userId
|
||||
lines.collect { case l: UserLine =>
|
||||
l.userId
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,13 +58,11 @@ final class ClasProgressApi(
|
|||
|
||||
val progressesFu = historyApi.progresses(users, perfType, days)
|
||||
|
||||
playStatsFu zip progressesFu map {
|
||||
case (playStats, progresses) =>
|
||||
playStatsFu zip progressesFu map { case (playStats, progresses) =>
|
||||
ClasProgress(
|
||||
perfType,
|
||||
days,
|
||||
users zip progresses map {
|
||||
case (u, rating) =>
|
||||
users zip progresses map { case (u, rating) =>
|
||||
val playStat = playStats get u.id
|
||||
u.id -> StudentProgress(
|
||||
nb = playStat.??(_.nb),
|
||||
|
|
|
@ -34,11 +34,10 @@ final class Env(
|
|||
lazy val markup = wire[ClasMarkup]
|
||||
|
||||
lila.common.Bus.subscribeFuns(
|
||||
"finishGame" -> {
|
||||
case lila.game.actorApi.FinishGame(game, _, _) => progressApi.onFinishGame(game)
|
||||
"finishGame" -> { case lila.game.actorApi.FinishGame(game, _, _) =>
|
||||
progressApi.onFinishGame(game)
|
||||
},
|
||||
"clas" -> {
|
||||
case lila.hub.actorApi.clas.IsTeacherOf(teacher, student, promise) =>
|
||||
"clas" -> { case lila.hub.actorApi.clas.IsTeacherOf(teacher, student, promise) =>
|
||||
promise completeWith api.clas.isTeacherOfStudent(teacher, Student.Id(student))
|
||||
}
|
||||
)
|
||||
|
|
|
@ -46,8 +46,8 @@ final class CoachPager(
|
|||
_.id
|
||||
)
|
||||
} map { users =>
|
||||
coaches zip users collect {
|
||||
case (coach, Some(user)) => Coach.WithUser(coach, user)
|
||||
coaches zip users collect { case (coach, Some(user)) =>
|
||||
Coach.WithUser(coach, user)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue