pull/7125/head
Thibault Duplessis 2020-08-16 14:43:26 +02:00
parent c6ed157217
commit d25ef1ff63
22 changed files with 99 additions and 72 deletions

View File

@ -48,9 +48,12 @@ object widget {
pic(c, if (link) 300 else 350),
div(cls := "overview")(
(if (link) h2 else h1)(cls := "coach-name")(titleName(c)),
c.coach.profile.headline.map { h =>
p(cls := s"headline ${if (h.length < 60) "small" else if (h.length < 120) "medium" else "large"}")(h)
},
c.coach.profile.headline
.map { h =>
p(
cls := s"headline ${if (h.length < 60) "small" else if (h.length < 120) "medium" else "large"}"
)(h)
},
table(
tbody(
tr(

View File

@ -94,7 +94,9 @@ object side {
div(cls := s"player color-icon is ${p.color.name} text")(
playerLink(p, withOnline = false, withDiff = true, withBerserk = true)
),
tour.flatMap(_.teamVs).map(_.teams(p.color)) map { teamLink(_, withIcon = false)(cls := "team") }
tour.flatMap(_.teamVs).map(_.teams(p.color)) map {
teamLink(_, withIcon = false)(cls := "team")
}
)
}
)

View File

@ -103,18 +103,20 @@ object bits {
div(cls := "now-playing")(
playing.partition(_.isMyTurn) pipe {
case (myTurn, otherTurn) =>
(myTurn ++ otherTurn.take(6 - myTurn.size)) take 9 map { pov =>
a(href := routes.Round.player(pov.fullId), cls := pov.isMyTurn.option("my_turn"))(
gameFen(pov, withLink = false, withTitle = false, withLive = false),
span(cls := "meta")(
playerText(pov.opponent, withRating = false),
span(cls := "indicator")(
if (pov.isMyTurn)
pov.remainingSeconds.fold[Frag](trans.yourTurn())(secondsFromNow(_, alwaysRelative = true))
else nbsp
(myTurn ++ otherTurn.take(6 - myTurn.size)) take 9 map {
pov =>
a(href := routes.Round.player(pov.fullId), cls := pov.isMyTurn.option("my_turn"))(
gameFen(pov, withLink = false, withTitle = false, withLive = false),
span(cls := "meta")(
playerText(pov.opponent, withRating = false),
span(cls := "indicator")(
if (pov.isMyTurn)
pov.remainingSeconds
.fold[Frag](trans.yourTurn())(secondsFromNow(_, alwaysRelative = true))
else nbsp
)
)
)
)
}
}
)

View File

@ -18,7 +18,9 @@ object header {
s.streamer.name
),
s.streamer.headline.map(_.value).map { d =>
p(cls := s"headline ${if (d.length < 60) "small" else if (d.length < 120) "medium" else "large"}")(d)
p(cls := s"headline ${if (d.length < 60) "small" else if (d.length < 120) "medium" else "large"}")(
d
)
},
div(cls := "services")(
s.streamer.twitch.map { twitch =>

View File

@ -34,7 +34,9 @@ object index {
div(cls := "overview")(
h1(dataIcon := "")(titleTag(s.user.title), stringValueFrag(s.streamer.name)),
s.streamer.headline.map(_.value).map { d =>
p(cls := s"headline ${if (d.length < 60) "small" else if (d.length < 120) "medium" else "large"}")(d)
p(
cls := s"headline ${if (d.length < 60) "small" else if (d.length < 120) "medium" else "large"}"
)(d)
},
div(cls := "services")(
s.streamer.twitch.map { twitch =>

View File

@ -15,6 +15,6 @@ private[appeal] object BsonHandlers {
s => BSONString(s.key)
)
implicit val appealMsgHandler = Macros.handler[AppealMsg]
implicit val appealHandler = Macros.handler[Appeal]
implicit val appealMsgHandler = Macros.handler[AppealMsg]
implicit val appealHandler = Macros.handler[Appeal]
}

View File

@ -7,7 +7,7 @@ import lila.common.config._
@Module
final class Env(
db: lila.db.Db,
userRepo: lila.user.UserRepo,
userRepo: lila.user.UserRepo
)(implicit ec: scala.concurrent.ExecutionContext) {
private val coll = db(CollName("appeal"))

View File

@ -179,13 +179,17 @@ trait CollExt { self: dsl with QueryBuilderExt =>
coll.update.one(selector, $set(field -> value))
def updateFieldUnchecked[V: BSONWriter](selector: Bdoc, field: String, value: V): Unit =
coll.update(ordered = false, writeConcern = WriteConcern.Unacknowledged).one(selector, $set(field -> value))
coll
.update(ordered = false, writeConcern = WriteConcern.Unacknowledged)
.one(selector, $set(field -> value))
def incField(selector: Bdoc, field: String, value: Int = 1) =
coll.update.one(selector, $inc(field -> value))
def incFieldUnchecked(selector: Bdoc, field: String, value: Int = 1): Unit =
coll.update(ordered = false, writeConcern = WriteConcern.Unacknowledged).one(selector, $inc(field -> value))
coll
.update(ordered = false, writeConcern = WriteConcern.Unacknowledged)
.one(selector, $inc(field -> value))
def unsetField(selector: Bdoc, field: String, multi: Boolean = false) =
coll.update.one(selector, $unset(field), multi = multi)

View File

@ -21,7 +21,8 @@ object EvalCacheSelector {
.sortBy(-_._1)
.map(_._2)
// then sort each group's evals, and keep only the best eval in each group
.map(_ sortBy ranking).flatMap(_.lastOption)
.map(_ sortBy ranking)
.flatMap(_.lastOption)
// now remove obsolete evals
.foldLeft(Nil: Evals) {
case (acc, e) if acc.exists { makesObsolete(_, e) } => acc

View File

@ -62,7 +62,8 @@ final class Analyser(
case true => fuFalse
case _ => {
import req._
val sender = Work.Sender(req.userId.some, none, mod = false, system = lila.user.User isOfficial req.userId)
val sender =
Work.Sender(req.userId.some, none, mod = false, system = lila.user.User isOfficial req.userId)
limiter(sender, ignoreConcurrentCheck = true) flatMap { accepted =>
if (!accepted) logger.info(s"Study request declined: ${req.studyId}/${req.chapterId} by $sender")
accepted ?? {

View File

@ -132,11 +132,11 @@ object Query {
options(1 to 5, "y", "%d year{s} ago")
val statuses = Status.finishedNotCheated.flatMap {
case s if s.is(_.Timeout) => none
case s if s.is(_.NoStart) => none
case s if s.is(_.Timeout) => none
case s if s.is(_.NoStart) => none
case s if s.is(_.UnknownFinish) => none
case s if s.is(_.Outoftime) => Some(s.id -> "Clock Flag")
case s if s.is(_.VariantEnd) => Some(s.id -> "Variant End")
case s => Some(s.id -> s.toString)
case s if s.is(_.Outoftime) => Some(s.id -> "Clock Flag")
case s if s.is(_.VariantEnd) => Some(s.id -> "Variant End")
case s => Some(s.id -> s.toString)
}
}

View File

@ -13,34 +13,38 @@ case class JsonQuestion(
for {
realMetric <- Metric.byKey get metric
realFilters =
filters.flatMap {
case (filterKey, valueKeys) => {
def build[X](dimension: Dimension[X]) =
Filter[X](dimension, valueKeys.flatMap {
Dimension.valueByKey(dimension, _)
}).some
filters
.flatMap {
case (filterKey, valueKeys) => {
def build[X](dimension: Dimension[X]) =
Filter[X](
dimension,
valueKeys.flatMap {
Dimension.valueByKey(dimension, _)
}
).some
filterKey match {
case Period.key => build(Period)
case Perf.key => build(Perf)
case Phase.key => build(Phase)
case Result.key => build(Result)
case Termination.key => build(Termination)
case Color.key => build(Color)
case Opening.key => build(Opening)
case OpponentStrength.key => build(OpponentStrength)
case PieceRole.key => build(PieceRole)
case MovetimeRange.key => build(MovetimeRange)
case MyCastling.key => build(MyCastling)
case OpCastling.key => build(OpCastling)
case QueenTrade.key => build(QueenTrade)
case MaterialRange.key => build(MaterialRange)
case Blur.key => build(Blur)
case TimeVariance.key => build(TimeVariance)
case _ => none
filterKey match {
case Period.key => build(Period)
case Perf.key => build(Perf)
case Phase.key => build(Phase)
case Result.key => build(Result)
case Termination.key => build(Termination)
case Color.key => build(Color)
case Opening.key => build(Opening)
case OpponentStrength.key => build(OpponentStrength)
case PieceRole.key => build(PieceRole)
case MovetimeRange.key => build(MovetimeRange)
case MyCastling.key => build(MyCastling)
case OpCastling.key => build(OpCastling)
case QueenTrade.key => build(QueenTrade)
case MaterialRange.key => build(MaterialRange)
case Blur.key => build(Blur)
case TimeVariance.key => build(TimeVariance)
case _ => none
}
}
}
}
.filterNot(_.isEmpty)
.toList
question <- {

View File

@ -23,7 +23,8 @@ final class MsgCompat(
def inbox(me: User, pageOpt: Option[Int]): Fu[JsObject] = {
val page = pageOpt.fold(1)(_ atLeast 1 atMost 2)
api.threadsOf(me) flatMap { allThreads =>
val threads = allThreads.slice((page - 1) * maxPerPage.value, (page - 1) * maxPerPage.value + maxPerPage.value)
val threads =
allThreads.slice((page - 1) * maxPerPage.value, (page - 1) * maxPerPage.value + maxPerPage.value)
lightUserApi.preloadMany(threads.map(_ other me)) inject
PaginatorJson {
Paginator

View File

@ -87,8 +87,9 @@ final class JSONHandlers(getLightUser: LightUser.GetterSync) {
}
implicit val andUnreadWrites: Writes[Notification.AndUnread] = Json.writes[Notification.AndUnread]
implicit val newNotificationWrites: Writes[NewNotification] = (newNotification: NewNotification) => Json.obj(
"notification" -> newNotification.notification,
"unread" -> newNotification.unreadNotifications
)
implicit val newNotificationWrites: Writes[NewNotification] = (newNotification: NewNotification) =>
Json.obj(
"notification" -> newNotification.notification,
"unread" -> newNotification.unreadNotifications
)
}

View File

@ -185,8 +185,8 @@ final private class StripeClient(
private def fixInput(in: Seq[(String, Any)]): Seq[(String, String)] =
in flatMap {
case (name, Some(x)) => Some(name -> x.toString)
case (_, None) => None
case (name, x) => Some(name -> x.toString)
case (_, None) => None
case (name, x) => Some(name -> x.toString)
}
private def listReader[A: Reads]: Reads[List[A]] = (__ \ "data").read[List[A]]

View File

@ -131,16 +131,16 @@ ${Mailgun.txt.serviceNote}
}
def onAppealReply(user: User): Funit = {
val body = s"""Hello,
val body = s"""Hello,
Your appeal has received a response from the moderation team: ${baseUrl}/appeal
$regards
"""
lila.common.Bus.publish(SystemMsg(user.id, body), "msgSystemSend")
funit
}
lila.common.Bus.publish(SystemMsg(user.id, body), "msgSystemSend")
funit
}
private def userLang(user: User) = user.realLang | lila.i18n.defaultLang
}

View File

@ -177,7 +177,8 @@ final class Store(val coll: Coll, cacheApi: lila.memo.CacheApi, localIp: IpAddre
val olds = sessions
.groupBy(_.compositeKey)
.view
.values.flatMap(_ drop 1)
.values
.flatMap(_ drop 1)
.filter(_._id != keepSessionId)
.map(_._id)
coll.delete.one($inIds(olds)).void

View File

@ -4,7 +4,9 @@ import lila.common.IpAddress
import play.api.libs.ws.StandaloneWSClient
final class Tor(ws: StandaloneWSClient, config: SecurityConfig.Tor)(implicit ec: scala.concurrent.ExecutionContext) {
final class Tor(ws: StandaloneWSClient, config: SecurityConfig.Tor)(implicit
ec: scala.concurrent.ExecutionContext
) {
private var ips = Set.empty[IpAddress]

View File

@ -130,8 +130,8 @@ final class RemoteSocket(
}
})
val subPromise = Promise[Unit]()
conn.async.subscribe(channel).thenRun {
() => subPromise.success(())
conn.async.subscribe(channel).thenRun { () =>
subPromise.success(())
}
subPromise.future
}

View File

@ -46,7 +46,8 @@ final class Env(
settingStore[UserIds](
"streamerAlwaysFeatured",
default = UserIds(Nil),
text = "Twitch streamers who get featured without the keyword - lichess usernames separated by a comma".some
text =
"Twitch streamers who get featured without the keyword - lichess usernames separated by a comma".some
)
}

View File

@ -172,8 +172,8 @@ final private class ChapterMaker(
str match {
case s if s.length == Game.gameIdSize => gameRepo game s
case s if s.length == Game.fullIdSize => gameRepo game Game.takeGameId(s)
case UrlRegex(id) => parseGame(id)
case _ => fuccess(none)
case UrlRegex(id) => parseGame(id)
case _ => fuccess(none)
}
}

View File

@ -19,7 +19,7 @@ object StudyTopic {
def fromStr(str: String): Option[StudyTopic] =
str.trim match {
case s if s.length >= minLength && s.length <= maxLength => StudyTopic(s).some
case _ => none
case _ => none
}
implicit val topicIso = lila.common.Iso.string[StudyTopic](StudyTopic.apply, _.value)