From f70900a485fcc6401fee85b28c3f78f019a54999 Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Thu, 29 Nov 2012 18:22:00 +0100 Subject: [PATCH] migration wip --- app/ai/stockfish/Client.scala | 2 +- app/ai/stockfish/Server.scala | 4 ++-- app/analyse/Analyser.scala | 2 +- app/analyse/Cached.scala | 2 +- app/controllers/LilaController.scala | 20 ++++++++--------- app/controllers/Monitor.scala | 2 +- app/controllers/Round.scala | 9 ++++---- app/controllers/Setting.scala | 4 ++-- app/controllers/Tournament.scala | 5 +++-- app/controllers/User.scala | 7 +++--- app/core/Cron.scala | 26 +++++++++++++--------- app/core/Global.scala | 2 +- app/core/IOFuture.scala | 5 ++--- app/core/Titivate.scala | 2 +- app/csv/Writer.scala | 2 +- app/forum/ForumHelper.scala | 15 ++++++------- app/forum/PostApi.scala | 12 +++------- app/game/Cached.scala | 2 +- app/game/Featured.scala | 4 ++-- app/game/GameHelper.scala | 33 ++++++++++++++-------------- app/implicits/RichDuration.scala | 17 -------------- app/lobby/Preload.scala | 2 +- app/lobby/Socket.scala | 2 +- app/memo/ActorMemo.scala | 4 ++-- app/monitor/Reporting.scala | 2 +- app/monitor/Socket.scala | 2 +- app/round/Hand.scala | 2 +- app/round/Hub.scala | 2 +- app/round/HubMaster.scala | 2 +- app/round/MoveNotifier.scala | 2 +- app/round/Socket.scala | 2 +- app/setup/FriendConfig.scala | 2 +- app/setup/HookConfig.scala | 6 ++--- app/site/Socket.scala | 2 +- app/socket/MetaHub.scala | 4 ++-- app/tournament/GameJoiner.scala | 2 +- app/tournament/Hub.scala | 2 +- app/tournament/HubMaster.scala | 2 +- app/tournament/Organizer.scala | 2 +- app/tournament/Reminder.scala | 2 +- app/tournament/Socket.scala | 2 +- app/user/Cached.scala | 2 +- app/user/UserRepo.scala | 6 ++--- project/Build.scala | 5 +++-- 44 files changed, 109 insertions(+), 129 deletions(-) delete mode 100644 app/implicits/RichDuration.scala diff --git a/app/ai/stockfish/Client.scala b/app/ai/stockfish/Client.scala index 728344451f..9d2f96eaf3 100644 --- a/app/ai/stockfish/Client.scala +++ b/app/ai/stockfish/Client.scala @@ -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 diff --git a/app/ai/stockfish/Server.scala b/app/ai/stockfish/Server.scala index 31de592065..390735f648 100644 --- a/app/ai/stockfish/Server.scala +++ b/app/ai/stockfish/Server.scala @@ -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 } diff --git a/app/analyse/Analyser.scala b/app/analyse/Analyser.scala index a5c100a3f9..0d514de493 100644 --- a/app/analyse/Analyser.scala +++ b/app/analyse/Analyser.scala @@ -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( diff --git a/app/analyse/Cached.scala b/app/analyse/Cached.scala index f9cc08aa31..32ff1d6092 100644 --- a/app/analyse/Cached.scala +++ b/app/analyse/Cached.scala @@ -1,7 +1,7 @@ package lila package analyse -import akka.util.duration._ +import scala.concurrent.duration._ import memo.ActorMemo diff --git a/app/controllers/LilaController.scala b/app/controllers/LilaController.scala index 256830b06c..a25f5992cf 100644 --- a/app/controllers/LilaController.scala +++ b/app/controllers/LilaController.scala @@ -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 diff --git a/app/controllers/Monitor.scala b/app/controllers/Monitor.scala index 0367390d17..ac82639bb4 100644 --- a/app/controllers/Monitor.scala +++ b/app/controllers/Monitor.scala @@ -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._ diff --git a/app/controllers/Round.scala b/app/controllers/Round.scala index 3f66cf08ae..7ff7a37daa 100644 --- a/app/controllers/Round.scala +++ b/app/controllers/Round.scala @@ -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()) + } }) } diff --git a/app/controllers/Setting.scala b/app/controllers/Setting.scala index 302aaa1770..ed0de0783c 100644 --- a/app/controllers/Setting.scala +++ b/app/controllers/Setting.scala @@ -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]) diff --git a/app/controllers/Tournament.scala b/app/controllers/Tournament.scala index 74c20ce36b..1d99720310 100644 --- a/app/controllers/Tournament.scala +++ b/app/controllers/Tournament.scala @@ -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) diff --git a/app/controllers/User.scala b/app/controllers/User.scala index b5a3d72e42..d1236e1147 100644 --- a/app/controllers/User.scala +++ b/app/controllers/User.scala @@ -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) } diff --git a/app/core/Cron.scala b/app/core/Cron.scala index 8607642a34..66a7f91e60 100644 --- a/app/core/Cron.scala +++ b/app/core/Cron.scala @@ -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 + } } diff --git a/app/core/Global.scala b/app/core/Global.scala index 5cb7b76adf..dc708fd839 100644 --- a/app/core/Global.scala +++ b/app/core/Global.scala @@ -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)) ) diff --git a/app/core/IOFuture.scala b/app/core/IOFuture.scala index d9ffa6f5d6..c044c66c31 100644 --- a/app/core/IOFuture.scala +++ b/app/core/IOFuture.scala @@ -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 { diff --git a/app/core/Titivate.scala b/app/core/Titivate.scala index 8a8845a64c..93f5772437 100644 --- a/app/core/Titivate.scala +++ b/app/core/Titivate.scala @@ -45,7 +45,7 @@ final class Titivate( ) val unsetNext = (id: String) ⇒ gameRepo.collection.update( DBObject("_id" -> id), - $unset("next") + $unset(Seq("next")) ) io { diff --git a/app/csv/Writer.scala b/app/csv/Writer.scala index e8d38df87e..e01f256eeb 100644 --- a/app/csv/Writer.scala +++ b/app/csv/Writer.scala @@ -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() diff --git a/app/forum/ForumHelper.scala b/app/forum/ForumHelper.scala index f0c6f61a97..35112061a1 100644 --- a/app/forum/ForumHelper.scala +++ b/app/forum/ForumHelper.scala @@ -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("""%s""" - .format(cssClass | "", authorName(post))) - ) + withOnline: Boolean = true) = post.userId.fold( + Html("""%s""".format(cssClass | "", authorName(post))) + ) { userId ⇒ + userIdLink(userId.some, cssClass = cssClass, withOnline = withOnline) + } } diff --git a/app/forum/PostApi.scala b/app/forum/PostApi.scala index 7c5129867e..8809888ec4 100644 --- a/app/forum/PostApi.scala +++ b/app/forum/PostApi.scala @@ -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( diff --git a/app/game/Cached.scala b/app/game/Cached.scala index 3a497229e2..0ff253fec4 100644 --- a/app/game/Cached.scala +++ b/app/game/Cached.scala @@ -1,7 +1,7 @@ package lila package game -import akka.util.duration._ +import scala.concurrent.duration._ import memo.ActorMemo diff --git a/app/game/Featured.scala b/app/game/Featured.scala index db5fea3abf..842684963e 100644 --- a/app/game/Featured.scala +++ b/app/game/Featured.scala @@ -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 diff --git a/app/game/GameHelper.scala b/app/game/GameHelper.scala index ce58d6781c..87e8e15774 100644 --- a/app/game/GameHelper.scala +++ b/app/game/GameHelper.scala @@ -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 ⇒ - """%s%s""".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( - """""" format trans.thisPlayerUsesChessComputerAssistance(), - "") - ) - }, """%s""".format( cssClass | "", player.aiLevel.fold(aiName, User.anonymous) ) - ) + ) { userId ⇒ + userIdToUsername(userId) |> { username ⇒ + """%s%s""".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( + """""" format trans.thisPlayerUsesChessComputerAssistance(), + "") + ) + } + } } def gameEndStatus(game: DbGame)(implicit ctx: Context): Html = game.status match { diff --git a/app/implicits/RichDuration.scala b/app/implicits/RichDuration.scala deleted file mode 100644 index c6601918ec..0000000000 --- a/app/implicits/RichDuration.scala +++ /dev/null @@ -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 - } -} diff --git a/app/lobby/Preload.scala b/app/lobby/Preload.scala index 2cdb96001f..ac5f4e75c6 100644 --- a/app/lobby/Preload.scala +++ b/app/lobby/Preload.scala @@ -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._ diff --git a/app/lobby/Socket.scala b/app/lobby/Socket.scala index 9fcf994aea..be53f9251c 100644 --- a/app/lobby/Socket.scala +++ b/app/lobby/Socket.scala @@ -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._ diff --git a/app/memo/ActorMemo.scala b/app/memo/ActorMemo.scala index 26c7bf402d..280074e199 100644 --- a/app/memo/ActorMemo.scala +++ b/app/memo/ActorMemo.scala @@ -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 diff --git a/app/monitor/Reporting.scala b/app/monitor/Reporting.scala index 169550a078..7724676470 100644 --- a/app/monitor/Reporting.scala +++ b/app/monitor/Reporting.scala @@ -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._ diff --git a/app/monitor/Socket.scala b/app/monitor/Socket.scala index 35c8d82776..2397a1a4f9 100644 --- a/app/monitor/Socket.scala +++ b/app/monitor/Socket.scala @@ -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._ diff --git a/app/round/Hand.scala b/app/round/Hand.scala index 02ee67bf09..1961ba6fde 100644 --- a/app/round/Hand.scala +++ b/app/round/Hand.scala @@ -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( diff --git a/app/round/Hub.scala b/app/round/Hub.scala index 2e1103e8a5..750c975601 100644 --- a/app/round/Hub.scala +++ b/app/round/Hub.scala @@ -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 diff --git a/app/round/HubMaster.scala b/app/round/HubMaster.scala index a3d5fb5c09..0665672202 100644 --- a/app/round/HubMaster.scala +++ b/app/round/HubMaster.scala @@ -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 diff --git a/app/round/MoveNotifier.scala b/app/round/MoveNotifier.scala index a4ee142c04..366931399a 100644 --- a/app/round/MoveNotifier.scala +++ b/app/round/MoveNotifier.scala @@ -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 diff --git a/app/round/Socket.scala b/app/round/Socket.scala index 3b111ac9c6..4beda54fe9 100644 --- a/app/round/Socket.scala +++ b/app/round/Socket.scala @@ -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._ diff --git a/app/setup/FriendConfig.scala b/app/setup/FriendConfig.scala index bdb1733b0f..010afed9f8 100644 --- a/app/setup/FriendConfig.scala +++ b/app/setup/FriendConfig.scala @@ -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( diff --git a/app/setup/HookConfig.scala b/app/setup/HookConfig.scala index 918aa07c0d..ad1b864908 100644 --- a/app/setup/HookConfig.scala +++ b/app/setup/HookConfig.scala @@ -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) } diff --git a/app/site/Socket.scala b/app/site/Socket.scala index 70f75c6abf..eb92b293be 100644 --- a/app/site/Socket.scala +++ b/app/site/Socket.scala @@ -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._ diff --git a/app/socket/MetaHub.scala b/app/socket/MetaHub.scala index 83edbd447f..e933368387 100644 --- a/app/socket/MetaHub.scala +++ b/app/socket/MetaHub.scala @@ -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 diff --git a/app/tournament/GameJoiner.scala b/app/tournament/GameJoiner.scala index d4e33274c1..60f7e26d1d 100644 --- a/app/tournament/GameJoiner.scala +++ b/app/tournament/GameJoiner.scala @@ -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, diff --git a/app/tournament/Hub.scala b/app/tournament/Hub.scala index f446baffcc..94818f3b5c 100644 --- a/app/tournament/Hub.scala +++ b/app/tournament/Hub.scala @@ -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 diff --git a/app/tournament/HubMaster.scala b/app/tournament/HubMaster.scala index 3fab01da68..94cfa8ac74 100644 --- a/app/tournament/HubMaster.scala +++ b/app/tournament/HubMaster.scala @@ -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 } diff --git a/app/tournament/Organizer.scala b/app/tournament/Organizer.scala index ba27572269..96f5529ce4 100644 --- a/app/tournament/Organizer.scala +++ b/app/tournament/Organizer.scala @@ -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 } diff --git a/app/tournament/Reminder.scala b/app/tournament/Reminder.scala index 1072fbbeb4..f45993dcdb 100644 --- a/app/tournament/Reminder.scala +++ b/app/tournament/Reminder.scala @@ -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 } diff --git a/app/tournament/Socket.scala b/app/tournament/Socket.scala index 3ee27e80c8..bc2034e13f 100644 --- a/app/tournament/Socket.scala +++ b/app/tournament/Socket.scala @@ -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._ diff --git a/app/user/Cached.scala b/app/user/Cached.scala index 0a1d8b3be7..0f84b6d6d8 100644 --- a/app/user/Cached.scala +++ b/app/user/Cached.scala @@ -3,7 +3,7 @@ package user import memo.ActorMemo -import akka.util.duration._ +import scala.concurrent.duration._ import scala.collection.mutable final class Cached( diff --git a/app/user/UserRepo.scala b/app/user/UserRepo.scala index e3eb0d898c..a508cbcd4a 100644 --- a/app/user/UserRepo.scala +++ b/app/user/UserRepo.scala @@ -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 { diff --git a/project/Build.scala b/project/Build.scala index 0a6ad3cd3c..2b75bb5f15 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -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(