migration wip
This commit is contained in:
parent
a3954d771a
commit
f70900a485
|
@ -9,7 +9,7 @@ import analyse.Analysis
|
|||
|
||||
import scalaz.effects._
|
||||
import akka.dispatch.Future
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import play.api.Play.current
|
||||
import play.api.libs.concurrent._
|
||||
import play.api.libs.ws.WS
|
||||
|
|
|
@ -9,8 +9,8 @@ import analyse.Analysis
|
|||
import model.{ GetQueueSize, QueueSize }
|
||||
|
||||
import akka.util.Timeout
|
||||
import akka.util.Duration
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.Duration
|
||||
import scala.concurrent.duration._
|
||||
import akka.dispatch.{ Future, Await }
|
||||
import akka.actor.{ Props, Actor, ActorRef, Kill }
|
||||
import akka.pattern.{ ask, AskTimeoutException }
|
||||
|
|
|
@ -7,7 +7,7 @@ import scalaz.effects._
|
|||
import play.api.libs.concurrent.Akka
|
||||
import play.api.Play.current
|
||||
import akka.dispatch.Future
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
|
||||
final class Analyser(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package lila
|
||||
package analyse
|
||||
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
|
||||
import memo.ActorMemo
|
||||
|
||||
|
|
|
@ -42,10 +42,10 @@ trait LilaController
|
|||
protected def Auth(f: Context ⇒ UserModel ⇒ Result): Action[AnyContent] =
|
||||
Auth(BodyParsers.parse.anyContent)(f)
|
||||
|
||||
protected def Auth[A](p: BodyParser[A])(f: Context ⇒ UserModel ⇒ Result): Action[A] =
|
||||
protected def Auth[A](p: BodyParser[A])(f: Context ⇒ UserModel ⇒ PlainResult): Action[A] =
|
||||
Action(p)(req ⇒ {
|
||||
val ctx = reqToCtx(req)
|
||||
ctx.me.fold(me ⇒ f(ctx)(me), authenticationFailed(ctx.req))
|
||||
ctx.me.fold(authenticationFailed(ctx.req))(me ⇒ f(ctx)(me))
|
||||
})
|
||||
|
||||
protected def AuthBody(f: BodyContext ⇒ UserModel ⇒ Result): Action[AnyContent] =
|
||||
|
@ -54,7 +54,7 @@ trait LilaController
|
|||
protected def AuthBody[A](p: BodyParser[A])(f: BodyContext ⇒ UserModel ⇒ Result): Action[A] =
|
||||
Action(p)(req ⇒ {
|
||||
val ctx = reqToCtx(req)
|
||||
ctx.me.fold(me ⇒ f(ctx)(me), authenticationFailed(ctx.req))
|
||||
ctx.me.fold(authenticationFailed(ctx.req))(me ⇒ f(ctx)(me))
|
||||
})
|
||||
|
||||
protected def Secure(perm: Permission)(f: Context ⇒ UserModel ⇒ Result): Action[AnyContent] =
|
||||
|
@ -75,7 +75,7 @@ trait LilaController
|
|||
)
|
||||
|
||||
protected def NoEngine[A <: Result](a: ⇒ A)(implicit ctx: Context): Result =
|
||||
ctx.me.fold(_.engine, false).fold(Forbidden(views.html.site.noEngine()), a)
|
||||
ctx.me.fold(false)(_.engine).fold(Forbidden(views.html.site.noEngine()), a)
|
||||
|
||||
protected def JsonOk(map: Map[String, Any]) = Ok(toJson(map)) as JSON
|
||||
|
||||
|
@ -125,10 +125,10 @@ trait LilaController
|
|||
implicit writer: Writeable[B],
|
||||
ctype: ContentTypeOf[B],
|
||||
ctx: Context) =
|
||||
oa.fold(a ⇒ Ok(op(a)), notFound(ctx))
|
||||
oa.fold(notFound(ctx))(a ⇒ Ok(op(a)))
|
||||
|
||||
protected def OptionResult[A](oa: Option[A])(op: A ⇒ Result)(implicit ctx: Context) =
|
||||
oa.fold(op, notFound(ctx))
|
||||
oa.fold(notFound(ctx))(op)
|
||||
|
||||
protected def IOptionOk[A, B](ioa: IO[Option[A]])(op: A ⇒ B)(
|
||||
implicit writer: Writeable[B],
|
||||
|
@ -147,20 +147,20 @@ trait LilaController
|
|||
} unsafePerformIO
|
||||
|
||||
protected def IOptionIOResult[A](ioa: IO[Option[A]])(op: A ⇒ IO[Result])(implicit ctx: Context) =
|
||||
ioa flatMap { _.fold(op, io(notFound(ctx))) } unsafePerformIO
|
||||
ioa flatMap { _.fold(op)(io(notFound(ctx))) } unsafePerformIO
|
||||
|
||||
protected def IOptionRedirect[A](ioa: IO[Option[A]])(op: A ⇒ Call)(implicit ctx: Context) =
|
||||
ioa map {
|
||||
_.fold(a ⇒ Redirect(op(a)), io(notFound(ctx)))
|
||||
_.fold(notFound(ctx))(a ⇒ Redirect(op(a)))
|
||||
} unsafePerformIO
|
||||
|
||||
protected def IOptionIORedirect[A](ioa: IO[Option[A]])(op: A ⇒ IO[Call])(implicit ctx: Context) =
|
||||
(ioa flatMap {
|
||||
_.fold(a ⇒ op(a) map { b ⇒ Redirect(b) }, io(notFound(ctx)))
|
||||
_.fold(io(notFound(ctx)))(a ⇒ op(a) map { b ⇒ Redirect(b) })
|
||||
}: IO[Result]).unsafePerformIO
|
||||
|
||||
protected def IOptionResult[A](ioa: IO[Option[A]])(op: A ⇒ Result)(implicit ctx: Context) =
|
||||
ioa.unsafePerformIO.fold(a ⇒ op(a), notFound(ctx))
|
||||
ioa.unsafePerformIO.fold(notFound(ctx))(a ⇒ op(a))
|
||||
|
||||
protected def notFound(implicit ctx: Context) = Lobby handleNotFound ctx
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ import play.api.libs.Comet
|
|||
import play.api.libs.concurrent._
|
||||
import play.api.libs.json._
|
||||
import akka.pattern.ask
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
|
||||
import lila._
|
||||
|
|
|
@ -140,12 +140,11 @@ object Round extends LilaController with TheftPrevention with RoundEventPerforme
|
|||
def players(gameId: String) = Open { implicit ctx ⇒
|
||||
import templating.Environment.playerLink
|
||||
JsonIOk(gameRepo game gameId map { gameOption ⇒
|
||||
gameOption.fold(
|
||||
game ⇒ (game.players collect {
|
||||
gameOption.fold(Map()) { game ⇒
|
||||
(game.players collect {
|
||||
case player if player.isHuman ⇒ player.color.name -> playerLink(player).text
|
||||
} toMap) ++ ctx.me.fold(me ⇒ Map("me" -> me.usernameWithElo), Map()),
|
||||
Map()
|
||||
)
|
||||
} toMap) ++ ctx.me.fold(me ⇒ Map("me" -> me.usernameWithElo), Map())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -22,14 +22,14 @@ object Setting extends LilaController {
|
|||
case "bg" ⇒ setBg.some
|
||||
case _ ⇒ none
|
||||
}
|
||||
setter.fold({
|
||||
setter.fold(notFound) {
|
||||
case (form, process) ⇒
|
||||
FormResult(form) { value ⇒
|
||||
Ok("ok") withCookies {
|
||||
process(HttpSetting(ctx), value).unsafePerformIO
|
||||
}
|
||||
}
|
||||
}, NotFound)
|
||||
}
|
||||
}
|
||||
|
||||
private type Setter = (Form[String], (HttpSetting, String) ⇒ IO[Cookie])
|
||||
|
|
|
@ -2,6 +2,7 @@ package controllers
|
|||
|
||||
import lila._
|
||||
import views._
|
||||
import game.Pov
|
||||
import tournament.{ Created, Started, Finished }
|
||||
import http.Context
|
||||
|
||||
|
@ -61,7 +62,7 @@ object Tournament extends LilaController {
|
|||
private def showStarted(tour: Started)(implicit ctx: Context) = for {
|
||||
roomHtml ← messenger render tour
|
||||
games ← gameRepo games (tour recentGameIds 4)
|
||||
pov ← tour.userCurrentPov(ctx.me).fold(gameRepo.pov, io(none))
|
||||
pov ← tour.userCurrentPov(ctx.me).fold(io(none[Pov]))(gameRepo.pov)
|
||||
} yield html.tournament.show.started(
|
||||
tour = tour,
|
||||
roomHtml = Html(roomHtml),
|
||||
|
@ -112,7 +113,7 @@ object Tournament extends LilaController {
|
|||
|
||||
private def reloadStarted(tour: Started)(implicit ctx: Context) = for {
|
||||
games ← gameRepo games (tour recentGameIds 4)
|
||||
pov ← tour.userCurrentPov(ctx.me).fold(gameRepo.pov, io(none))
|
||||
pov ← tour.userCurrentPov(ctx.me).fold(io(none[Pov]))(gameRepo.pov)
|
||||
} yield {
|
||||
val pairings = html.tournament.pairings(tour)
|
||||
val inner = html.tournament.show.startedInner(tour, games, pov)
|
||||
|
|
|
@ -59,10 +59,9 @@ object User extends LilaController {
|
|||
}
|
||||
|
||||
val autocomplete = Action { implicit req ⇒
|
||||
get("term", req).filter(""!=).fold(
|
||||
term ⇒ JsonOk((userRepo usernamesLike term).unsafePerformIO),
|
||||
BadRequest("No search term provided")
|
||||
)
|
||||
get("term", req).filter(""!=).fold(BadRequest("No search term provided")) { term ⇒
|
||||
JsonOk((userRepo usernamesLike term).unsafePerformIO)
|
||||
}
|
||||
}
|
||||
|
||||
val getBio = Auth { ctx ⇒ me ⇒ Ok(me.bio) }
|
||||
|
|
|
@ -3,15 +3,13 @@ package core
|
|||
|
||||
import akka.actor.ActorRef
|
||||
import akka.pattern.{ ask, pipe }
|
||||
import akka.dispatch.{ Future, Promise }
|
||||
import akka.util.duration._
|
||||
import akka.util.{ Duration, Timeout }
|
||||
import play.api.Mode
|
||||
import akka.util.Timeout
|
||||
import scala.concurrent.duration._
|
||||
import play.api.libs.concurrent.Execution.Implicits._
|
||||
import play.api.libs.concurrent._
|
||||
import play.api.Mode
|
||||
import scalaz.effects._
|
||||
|
||||
import implicits.RichDuration._
|
||||
|
||||
object Cron {
|
||||
|
||||
def start(env: CoreEnv) {
|
||||
|
@ -101,12 +99,12 @@ object Cron {
|
|||
env.tournament.organizer -> tournament.StartPairings
|
||||
}
|
||||
|
||||
def message(freq: Duration)(to: (ActorRef, Any)) {
|
||||
Akka.system.scheduler.schedule(freq, freq.randomize(), to._1, to._2)
|
||||
def message(freq: FiniteDuration)(to: (ActorRef, Any)) {
|
||||
Akka.system.scheduler.schedule(freq, randomize(freq), to._1, to._2)
|
||||
}
|
||||
|
||||
def effect(freq: Duration, name: String)(op: ⇒ IO[_]) {
|
||||
val f = freq.randomize()
|
||||
val f = randomize(freq)
|
||||
println("schedule effect %s every %s -> %s".format(name, freq, f))
|
||||
Akka.system.scheduler.schedule(f, f) {
|
||||
tryNamed(name, op.unsafePerformIO)
|
||||
|
@ -114,7 +112,7 @@ object Cron {
|
|||
}
|
||||
|
||||
def unsafe(freq: Duration, name: String)(op: ⇒ Unit) {
|
||||
Akka.system.scheduler.schedule(freq, freq.randomize()) {
|
||||
Akka.system.scheduler.schedule(freq, randomize(freq)) {
|
||||
tryNamed(name, op)
|
||||
}
|
||||
}
|
||||
|
@ -128,4 +126,12 @@ object Cron {
|
|||
case e: Exception ⇒ println("[CRON ERROR] (" + name + ") " + e.getMessage)
|
||||
}
|
||||
}
|
||||
|
||||
private def randomize(d: Duration, ratio: Float = 0.1f): FiniteDuration = {
|
||||
import scala.util.Random
|
||||
import scala.math.round
|
||||
import ornicar.scalalib.Random.approximatly
|
||||
|
||||
approximatly(0.1f)(d.toMillis) millis
|
||||
}
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ object Global extends GlobalSettings {
|
|||
override def onError(request: RequestHeader, ex: Throwable) =
|
||||
env.ai.isServer.fold(
|
||||
InternalServerError(ex.getMessage),
|
||||
Option(coreEnv).fold(_.app.mode, Mode.Prod) match {
|
||||
Option(coreEnv).fold(Mode.Prod)(_.app.mode) match {
|
||||
case Mode.Prod ⇒ InternalServerError(
|
||||
views.html.base.errorPage(ex)(http.Context(request, none))
|
||||
)
|
||||
|
|
|
@ -3,10 +3,9 @@ package core
|
|||
|
||||
import play.api.Play.current
|
||||
import play.api.libs.concurrent._
|
||||
import akka.dispatch.{ Future, Await }
|
||||
import akka.util.Timeout
|
||||
import akka.util.Duration
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.{ Future, Await }
|
||||
import scala.concurrent.duration._
|
||||
import scalaz.effects._
|
||||
|
||||
trait Futuristic {
|
||||
|
|
|
@ -45,7 +45,7 @@ final class Titivate(
|
|||
)
|
||||
val unsetNext = (id: String) ⇒ gameRepo.collection.update(
|
||||
DBObject("_id" -> id),
|
||||
$unset("next")
|
||||
$unset(Seq("next"))
|
||||
)
|
||||
|
||||
io {
|
||||
|
|
|
@ -17,7 +17,7 @@ object Writer {
|
|||
file.exists.fold(
|
||||
io(webPath), {
|
||||
println("Export " + file)
|
||||
val writer = new CSVWriter(file)
|
||||
val writer = new CSVWriter(file, "UTF-8")
|
||||
io {
|
||||
writer writeAll lines.map(_ map (_.toString))
|
||||
writer.close()
|
||||
|
|
|
@ -9,15 +9,14 @@ import play.api.templates.Html
|
|||
trait ForumHelper { self: UserHelper with StringHelper ⇒
|
||||
|
||||
def authorName(post: Post) =
|
||||
post.userId.fold(userIdToUsername, escape(post.showAuthor))
|
||||
post.userId.fold(escape(post.showAuthor))(userIdToUsername)
|
||||
|
||||
def authorLink(
|
||||
post: Post,
|
||||
post: Post,
|
||||
cssClass: Option[String] = None,
|
||||
withOnline: Boolean = true) =
|
||||
post.userId.fold(
|
||||
userId ⇒ userIdLink(userId.some, cssClass = cssClass, withOnline = withOnline),
|
||||
Html("""<span class="%s">%s</span>"""
|
||||
.format(cssClass | "", authorName(post)))
|
||||
)
|
||||
withOnline: Boolean = true) = post.userId.fold(
|
||||
Html("""<span class="%s">%s</span>""".format(cssClass | "", authorName(post)))
|
||||
) { userId ⇒
|
||||
userIdLink(userId.some, cssClass = cssClass, withOnline = withOnline)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,18 +49,12 @@ final class PostApi(
|
|||
|
||||
def get(postId: String): IO[Option[(Topic, Post)]] = for {
|
||||
postOption ← env.postRepo byId postId
|
||||
topicOption ← postOption.fold(
|
||||
post ⇒ env.topicRepo byId post.topicId,
|
||||
io(none[Topic])
|
||||
)
|
||||
topicOption ← postOption.fold(io(none[Topic]))(post ⇒ env.topicRepo byId post.topicId)
|
||||
} yield (topicOption |@| postOption).tupled
|
||||
|
||||
def view(post: Post): IO[Option[PostView]] = for {
|
||||
topicOption ← env.topicRepo byId post.topicId
|
||||
categOption ← topicOption.fold(
|
||||
topic ⇒ env.categRepo bySlug topic.categId,
|
||||
io(none[Categ])
|
||||
)
|
||||
categOption ← topicOption.fold(io(none[Categ]))(topic ⇒ env.categRepo bySlug topic.categId)
|
||||
} yield topicOption |@| categOption apply {
|
||||
case (topic, categ) ⇒ PostView(post, topic, categ, lastPageOf(topic))
|
||||
}
|
||||
|
@ -83,7 +77,7 @@ final class PostApi(
|
|||
|
||||
def delete(postId: String, mod: User): IO[Unit] = for {
|
||||
postOption ← env.postRepo byId postId
|
||||
viewOption ← postOption.fold(view, io(none))
|
||||
viewOption ← postOption.fold(io(none))(view)
|
||||
_ ← viewOption.fold(
|
||||
view ⇒ for {
|
||||
_ ← (view.topic.nbPosts == 1).fold(
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package lila
|
||||
package game
|
||||
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
|
||||
import memo.ActorMemo
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ package game
|
|||
import akka.actor._
|
||||
import akka.dispatch.{ Future, Await }
|
||||
import akka.pattern.ask
|
||||
import akka.util.Duration
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.Duration
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
import play.api.Play.current
|
||||
import play.api.libs.concurrent.Akka
|
||||
|
|
|
@ -45,26 +45,27 @@ trait GameHelper { self: I18nHelper with UserHelper with StringHelper with AiHel
|
|||
withDiff: Boolean = true,
|
||||
engine: Boolean = false)(implicit ctx: Context) = Html {
|
||||
player.userId.fold(
|
||||
userId ⇒ userIdToUsername(userId) |> { username ⇒
|
||||
"""<a class="user_link%s%s" href="%s">%s%s</a>""".format(
|
||||
cssClass.fold(" " + _, ""),
|
||||
withOnline.fold(
|
||||
isUsernameOnline(username).fold(" online", " offline"),
|
||||
""),
|
||||
routes.User.show(username),
|
||||
usernameWithElo(player) + player.eloDiff.filter(_ ⇒ withDiff).fold(
|
||||
diff ⇒ " (%s)".format(showNumber(diff)),
|
||||
""),
|
||||
engine.fold(
|
||||
"""<span class="engine_mark" title="%s"></span>""" format trans.thisPlayerUsesChessComputerAssistance(),
|
||||
"")
|
||||
)
|
||||
},
|
||||
"""<span class="user_link %s">%s</span>""".format(
|
||||
cssClass | "",
|
||||
player.aiLevel.fold(aiName, User.anonymous)
|
||||
)
|
||||
)
|
||||
) { userId ⇒
|
||||
userIdToUsername(userId) |> { username ⇒
|
||||
"""<a class="user_link%s%s" href="%s">%s%s</a>""".format(
|
||||
cssClass.fold(" " + _, ""),
|
||||
withOnline.fold(
|
||||
isUsernameOnline(username).fold(" online", " offline"),
|
||||
""),
|
||||
routes.User.show(username),
|
||||
usernameWithElo(player) + player.eloDiff.filter(_ ⇒ withDiff).fold(
|
||||
diff ⇒ " (%s)".format(showNumber(diff)),
|
||||
""),
|
||||
engine.fold(
|
||||
"""<span class="engine_mark" title="%s"></span>""" format trans.thisPlayerUsesChessComputerAssistance(),
|
||||
"")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def gameEndStatus(game: DbGame)(implicit ctx: Context): Html = game.status match {
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
package lila
|
||||
package implicits
|
||||
|
||||
import akka.util.Duration
|
||||
import akka.util.duration._
|
||||
import scala.util.Random
|
||||
import scala.math.round
|
||||
import ornicar.scalalib.Random.approximatly
|
||||
|
||||
object RichDuration {
|
||||
|
||||
implicit def richDuration(d: Duration) = new {
|
||||
|
||||
def randomize(ratio: Float = 0.1f): Duration =
|
||||
approximatly(0.1f)(d.toMillis) millis
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@ import play.api.mvc.Call
|
|||
import play.api.libs.concurrent.Akka
|
||||
import play.api.Play.current
|
||||
import akka.dispatch.Future
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
import scalaz.effects._
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package lobby
|
|||
|
||||
import akka.actor._
|
||||
import akka.pattern.ask
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
import play.api.libs.json._
|
||||
import play.api.libs.iteratee._
|
||||
|
|
|
@ -4,8 +4,8 @@ package memo
|
|||
import akka.actor._
|
||||
import akka.dispatch.{ Future, Await }
|
||||
import akka.pattern.ask
|
||||
import akka.util.Duration
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.Duration
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
|
||||
import play.api.Play.current
|
||||
|
|
|
@ -6,7 +6,7 @@ import round.GetNbHubs
|
|||
|
||||
import akka.actor._
|
||||
import akka.pattern.{ ask, pipe }
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.{ Duration, Timeout }
|
||||
import akka.dispatch.{ Future, Promise }
|
||||
import play.api.libs.concurrent._
|
||||
|
|
|
@ -3,7 +3,7 @@ package monitor
|
|||
|
||||
import akka.actor._
|
||||
import akka.pattern.ask
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
import play.api.libs.json._
|
||||
import play.api.libs.iteratee._
|
||||
|
|
|
@ -12,7 +12,7 @@ import scalaz.effects._
|
|||
import akka.actor._
|
||||
import akka.dispatch.{ Future, Await }
|
||||
import akka.pattern.ask
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
|
||||
final class Hand(
|
||||
|
|
|
@ -5,7 +5,7 @@ import socket._
|
|||
import chess.{ Color, White, Black }
|
||||
|
||||
import akka.actor._
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import play.api.libs.json._
|
||||
import play.api.libs.iteratee._
|
||||
import play.api.Play.current
|
||||
|
|
|
@ -5,7 +5,7 @@ import socket.{ Broom, Close, GetNbMembers, GetUsernames, NbMembers, SendTo, Sen
|
|||
|
||||
import akka.actor._
|
||||
import akka.actor.ReceiveTimeout
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
import akka.pattern.{ ask, pipe }
|
||||
import akka.dispatch.Future
|
||||
|
|
|
@ -5,7 +5,7 @@ import socket.Fen
|
|||
|
||||
import scalaz.effects._
|
||||
import akka.actor._
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
import play.api.libs.concurrent._
|
||||
import play.api.Play.current
|
||||
|
|
|
@ -3,7 +3,7 @@ package round
|
|||
|
||||
import akka.actor._
|
||||
import akka.pattern.ask
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
import akka.dispatch.Await
|
||||
import play.api.libs.json._
|
||||
|
|
|
@ -40,7 +40,7 @@ object FriendConfig extends BaseHumanConfig {
|
|||
clock = k,
|
||||
time = t,
|
||||
increment = i,
|
||||
mode = m.fold(Mode.orDefault, Mode.default),
|
||||
mode = m.fold(Mode.default)(Mode.orDefault),
|
||||
color = Color(c) err "Invalid color " + c)
|
||||
|
||||
val default = FriendConfig(
|
||||
|
|
|
@ -39,16 +39,14 @@ case class HookConfig(
|
|||
object HookConfig extends BaseHumanConfig {
|
||||
|
||||
def <<(v: Int, k: Boolean, t: Int, i: Int, m: Option[Int], e: Option[String], c: String) = {
|
||||
val realMode = m.fold(Mode.orDefault, Mode.default)
|
||||
val realMode = m.fold(Mode.default)(Mode.orDefault)
|
||||
new HookConfig(
|
||||
variant = Variant(v) err "Invalid game variant " + v,
|
||||
clock = k,
|
||||
time = t,
|
||||
increment = i,
|
||||
mode = realMode,
|
||||
eloRange = e.filter(_ ⇒ realMode.rated).fold(
|
||||
EloRange.orDefault,
|
||||
EloRange.default),
|
||||
eloRange = e.filter(_ ⇒ realMode.rated).fold(EloRange.default)(EloRange.orDefault),
|
||||
color = Color(c) err "Invalid color " + c)
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ package site
|
|||
|
||||
import akka.actor._
|
||||
import akka.pattern.ask
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
import play.api.libs.json._
|
||||
import play.api.libs.iteratee._
|
||||
|
|
|
@ -3,8 +3,8 @@ package socket
|
|||
|
||||
import akka.actor.ActorRef
|
||||
import akka.pattern.{ ask, pipe }
|
||||
import akka.dispatch.{ Future, Promise }
|
||||
import akka.util.duration._
|
||||
import scala.concurrent._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.{ Duration, Timeout }
|
||||
import play.api.libs.concurrent._
|
||||
import play.api.Play.current
|
||||
|
|
|
@ -9,7 +9,7 @@ import round.Meddler
|
|||
import scalaz.effects._
|
||||
import play.api.libs.concurrent._
|
||||
import play.api.Play.current
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
|
||||
final class GameJoiner(
|
||||
gameRepo: GameRepo,
|
||||
|
|
|
@ -6,7 +6,7 @@ import socket._
|
|||
import memo.BooleanExpiryMemo
|
||||
|
||||
import akka.actor._
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import play.api.libs.json._
|
||||
import play.api.libs.iteratee._
|
||||
import play.api.Play.current
|
||||
|
|
|
@ -5,7 +5,7 @@ import socket.{ History, Broom, Close, GetNbMembers, GetUsernames, NbMembers, Se
|
|||
|
||||
import akka.actor._
|
||||
import akka.actor.ReceiveTimeout
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
import akka.pattern.{ ask, pipe }
|
||||
import akka.dispatch.{ Future, Promise }
|
||||
|
|
|
@ -5,7 +5,7 @@ import game.DbGame
|
|||
import round.FinishGame
|
||||
|
||||
import akka.actor._
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
import akka.pattern.{ ask, pipe }
|
||||
import akka.dispatch.{ Future, Promise }
|
||||
|
|
|
@ -3,7 +3,7 @@ package tournament
|
|||
|
||||
import akka.actor._
|
||||
import akka.actor.ReceiveTimeout
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
import akka.pattern.{ ask, pipe }
|
||||
import akka.dispatch.{ Future, Promise }
|
||||
|
|
|
@ -3,7 +3,7 @@ package tournament
|
|||
|
||||
import akka.actor._
|
||||
import akka.pattern.ask
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import akka.util.Timeout
|
||||
import akka.dispatch.Await
|
||||
import play.api.libs.json._
|
||||
|
|
|
@ -3,7 +3,7 @@ package user
|
|||
|
||||
import memo.ActorMemo
|
||||
|
||||
import akka.util.duration._
|
||||
import scala.concurrent.duration._
|
||||
import scala.collection.mutable
|
||||
|
||||
final class Cached(
|
||||
|
|
|
@ -171,11 +171,11 @@ class UserRepo(collection: MongoCollection)
|
|||
collection.find(byIdQuery(username) ++ DBObject("engine" -> true)).size != 0
|
||||
}
|
||||
|
||||
def setBio(user: User, bio: String) = updateIO(user)($set("bio" -> bio))
|
||||
def setBio(user: User, bio: String) = updateIO(user)($set(Seq("bio" -> bio)))
|
||||
|
||||
def enable(user: User) = updateIO(user)($set("enabled" -> true))
|
||||
def enable(user: User) = updateIO(user)($set(Seq("enabled" -> true)))
|
||||
|
||||
def disable(user: User) = updateIO(user)($set("enabled" -> false))
|
||||
def disable(user: User) = updateIO(user)($set(Seq("enabled" -> false)))
|
||||
|
||||
def passwd(user: User, password: String): IO[Valid[Unit]] = for {
|
||||
obj ← io {
|
||||
|
|
|
@ -32,6 +32,7 @@ trait Dependencies {
|
|||
val jodaTime = "joda-time" % "joda-time" % "2.1"
|
||||
val jodaConvert = "org.joda" % "joda-convert" % "1.2"
|
||||
val scalastic = "com.traackr" % "scalastic_2.9.2" % "0.0.6-HACKED"
|
||||
val findbugs = "com.google.code.findbugs" % "jsr305" % "1.3.+"
|
||||
}
|
||||
|
||||
object ApplicationBuild extends Build with Resolvers with Dependencies {
|
||||
|
@ -45,12 +46,12 @@ object ApplicationBuild extends Build with Resolvers with Dependencies {
|
|||
"-deprecation",
|
||||
"-unchecked",
|
||||
"-feature",
|
||||
"-language:implicitConversions,reflectiveCalls,postfixOps,higherKinds,existentials")
|
||||
"-language:_")
|
||||
)
|
||||
|
||||
lazy val lila = play.Project("lila", "3", Seq(
|
||||
scalaz, scalalib, hasher, config, salat, guava, apache, scalaTime,
|
||||
paginator, paginatorSalat, csv, jgit, actuarius, scalastic
|
||||
paginator, paginatorSalat, csv, jgit, actuarius, scalastic, findbugs
|
||||
), settings = Defaults.defaultSettings ++ buildSettings).settings(
|
||||
scalaVersion := "2.10.0-RC3",
|
||||
templatesImport ++= Seq(
|
||||
|
|
Loading…
Reference in a new issue