2.12 migration WIP
parent
71668b8b5c
commit
40e71ecc31
|
@ -128,7 +128,7 @@ object Env {
|
|||
lazy val current = "app" boot new Env(
|
||||
config = lila.common.PlayApp.loadConfig,
|
||||
scheduler = lila.common.PlayApp.scheduler,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
appPath = lila.common.PlayApp withApp (_.path.getCanonicalPath)
|
||||
)
|
||||
|
||||
|
|
|
@ -283,7 +283,7 @@ object Round extends LilaController with TheftPrevention {
|
|||
} else {
|
||||
env resign pov
|
||||
import scala.concurrent.duration._
|
||||
val scheduler = lila.common.PlayApp.system.scheduler
|
||||
val scheduler = old.play.Env.actorSystem.scheduler
|
||||
akka.pattern.after(500 millis, scheduler)(fuccess(routes.Lobby.home))
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,7 +155,7 @@ lazy val search = module("search", Seq(common, hub)).settings(
|
|||
)
|
||||
|
||||
lazy val chat = module("chat", Seq(common, db, user, security, i18n, socket)).settings(
|
||||
libraryDependencies ++= provided(play.api, reactivemongo.driver)
|
||||
libraryDependencies ++= provided(play.api, play.jodaJson, reactivemongo.driver)
|
||||
)
|
||||
|
||||
lazy val timeline = module("timeline", Seq(common, db, game, user, hub, security, relation)).settings(
|
||||
|
@ -172,11 +172,11 @@ lazy val mod = module("mod", Seq(common, db, user, hub, security, tournament, si
|
|||
)
|
||||
|
||||
lazy val user = module("user", Seq(common, memo, db, hub, rating)).settings(
|
||||
libraryDependencies ++= provided(play.api, play.test, reactivemongo.driver, hasher)
|
||||
libraryDependencies ++= provided(play.api, play.test, play.jodaJson, reactivemongo.driver, hasher)
|
||||
)
|
||||
|
||||
lazy val game = module("game", Seq(common, memo, db, hub, user, chat)).settings(
|
||||
libraryDependencies ++= provided(play.api, reactivemongo.driver, reactivemongo.iteratees)
|
||||
libraryDependencies ++= provided(play.api, play.iteratee, play.jodaJson, reactivemongo.driver, reactivemongo.iteratees)
|
||||
)
|
||||
|
||||
lazy val gameSearch = module("gameSearch", Seq(common, hub, search, game)).settings(
|
||||
|
@ -388,7 +388,7 @@ lazy val tree = module("tree", Seq(common)).settings(
|
|||
)
|
||||
|
||||
lazy val socket = module("socket", Seq(common, hub, memo, tree)).settings(
|
||||
libraryDependencies ++= provided(play.api)
|
||||
libraryDependencies ++= provided(play.api, play.iteratee)
|
||||
)
|
||||
|
||||
lazy val hub = module("hub", Seq(common)).settings(
|
||||
|
|
|
@ -70,7 +70,7 @@ object Env {
|
|||
lazy val current: Env = "activity" boot new Env(
|
||||
db = lila.db.Env.current,
|
||||
config = lila.common.PlayApp loadConfig "activity",
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
practiceApi = lila.practice.Env.current.api,
|
||||
postApi = lila.forum.Env.current.postApi,
|
||||
simulApi = lila.simul.Env.current.api,
|
||||
|
|
|
@ -46,7 +46,7 @@ object Env {
|
|||
lazy val current = "analyse" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "analyse",
|
||||
db = lila.db.Env.current,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
evalCacheHandler = lila.evalCache.Env.current.socketHandler,
|
||||
hub = lila.hub.Env.current,
|
||||
roundSocket = lila.hub.Env.current.socket.round,
|
||||
|
|
|
@ -154,7 +154,7 @@ object Env {
|
|||
prefApi = lila.pref.Env.current.api,
|
||||
gamePgnDump = lila.game.Env.current.pgnDump,
|
||||
gameCache = lila.game.Env.current.cached,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
scheduler = lila.common.PlayApp.scheduler,
|
||||
pools = lila.pool.Env.current.api.configs,
|
||||
isProd = lila.common.PlayApp.isProd
|
||||
|
|
|
@ -44,6 +44,6 @@ object Env {
|
|||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
timelineApi = lila.timeline.Env.current.entryApi
|
||||
)(
|
||||
lila.common.PlayApp.system
|
||||
old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ object Env {
|
|||
|
||||
lazy val current = "bookmark" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "bookmark",
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
db = lila.db.Env.current
|
||||
)
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ object Env {
|
|||
|
||||
lazy val current: Env = "challenge" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "challenge",
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
onStart = lila.game.Env.current.onStart,
|
||||
hub = lila.hub.Env.current,
|
||||
gameCache = lila.game.Env.current.cached,
|
||||
|
|
|
@ -62,6 +62,6 @@ object Env {
|
|||
shutup = lila.hub.Env.current.actor.shutup,
|
||||
modLog = lila.hub.Env.current.actor.mod,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package lila.chat
|
|||
import lila.common.LightUser
|
||||
import lila.common.PimpedJson._
|
||||
import play.api.libs.json._
|
||||
import play.api.libs.json.JodaWrites._
|
||||
|
||||
object JsonView {
|
||||
|
||||
|
@ -13,11 +14,6 @@ object JsonView {
|
|||
|
||||
def apply(line: Line): JsValue = lineWriter writes line
|
||||
|
||||
def userModInfo(u: UserModInfo)(implicit lightUser: LightUser.GetterSync) =
|
||||
lila.user.JsonView.modWrites.writes(u.user) ++ Json.obj(
|
||||
"history" -> u.history
|
||||
)
|
||||
|
||||
implicit val chatIdWrites: Writes[Chat.Id] = stringIsoWriter(Chat.chatIdIso)
|
||||
|
||||
lazy val timeoutReasons = Json toJson ChatTimeout.Reason.all
|
||||
|
@ -60,4 +56,9 @@ object JsonView {
|
|||
"t" -> l.text
|
||||
)
|
||||
}
|
||||
|
||||
def userModInfo(u: UserModInfo)(implicit lightUser: LightUser.GetterSync) =
|
||||
lila.user.JsonView.modWrites.writes(u.user) ++ Json.obj(
|
||||
"history" -> u.history
|
||||
)
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ object Env {
|
|||
config = lila.common.PlayApp loadConfig "coach",
|
||||
notifyApi = lila.notify.Env.current.api,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
db = lila.db.Env.current
|
||||
)
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ object Env {
|
|||
lazy val mode: Mode = application.mode
|
||||
lazy val scheduler: Scheduler = actorSystem.scheduler
|
||||
lazy val injector: Injector = application.injector
|
||||
lazy val playExecutionContext: ExecutionContext = injector.instanceOf(classOf[ExecutionContext])
|
||||
lazy val defaultContext: ExecutionContext = injector.instanceOf(classOf[ExecutionContext])
|
||||
lazy val environment: Environment = injector.instanceOf(classOf[Environment])
|
||||
lazy val WS: WSClient = injector.instanceOf(classOf[WSClient])
|
||||
// lazy val cache: CacheApi = injector.instanceOf(classOf[CacheApi])
|
||||
|
@ -53,7 +53,7 @@ trait GoodOldPlay {
|
|||
implicit def defaultActorSystem: ActorSystem = Env.actorSystem
|
||||
implicit def defaultMaterializer: Materializer = Env.materializer
|
||||
implicit def defaultScheduler: Scheduler = Env.scheduler
|
||||
implicit def defaultContext: ExecutionContext = Env.playExecutionContext
|
||||
implicit def defaultContext: ExecutionContext = Env.defaultContext
|
||||
}
|
||||
|
||||
def WS = Env.WS
|
||||
|
@ -63,7 +63,7 @@ trait GoodOldPlay {
|
|||
def Mode = Env.configuration
|
||||
|
||||
def currentApplication = Env.application
|
||||
def defaultContext = Env.playExecutionContext
|
||||
def defaultContext = Env.defaultContext
|
||||
def defaultScheduler = Env.scheduler
|
||||
def defaultMaterializer = Env.scheduler
|
||||
def defaultActorSystem = Env.configuration
|
||||
|
@ -106,9 +106,9 @@ object api {
|
|||
}
|
||||
object Execution {
|
||||
object Implicits {
|
||||
implicit def defaultContext: ExecutionContext = Env.playExecutionContext
|
||||
implicit def defaultContext: ExecutionContext = Env.defaultContext
|
||||
}
|
||||
def defaultContext: ExecutionContext = Env.playExecutionContext
|
||||
def defaultContext: ExecutionContext = Env.defaultContext
|
||||
// def httpRequestsContext = Env.httpRequestExecContext
|
||||
// def httpCallsContext = Env.httpCallsExecContext
|
||||
// def dataStoreContext = Env.dataStoreExecContext
|
||||
|
|
|
@ -105,7 +105,7 @@ trait WithPlay { self: PackageObject =>
|
|||
import play.api.libs.json._
|
||||
import scalalib.Zero
|
||||
|
||||
implicit def playExecutionContext = play.api.libs.concurrent.Execution.defaultContext
|
||||
implicit def playExecutionContext = old.play.Env.defaultContext
|
||||
val directEC = lila.PimpedFuture.DirectExecutionContext
|
||||
|
||||
implicit val LilaFutureMonad = new Monad[Fu] {
|
||||
|
@ -150,7 +150,7 @@ trait WithPlay { self: PackageObject =>
|
|||
|
||||
implicit final class LilaPimpedFutureOption[A](fua: Fu[Option[A]]) {
|
||||
|
||||
def flatten(msg: => String): Fu[A] = fua flatMap {
|
||||
def err(msg: => String): Fu[A] = fua flatMap {
|
||||
_.fold[Fu[A]](fufail(msg))(fuccess(_))
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ import com.typesafe.config.Config
|
|||
import org.joda.time.{ DateTime, Period }
|
||||
import play.api.i18n.Lang
|
||||
import play.api.{ Play, Application, Mode }
|
||||
import scala.collection.JavaConversions._
|
||||
import scala.collection.JavaConverters._
|
||||
|
||||
object PlayApp {
|
||||
|
||||
|
@ -24,13 +24,13 @@ object PlayApp {
|
|||
def loadConfig(prefix: String): Config = loadConfig getConfig prefix
|
||||
|
||||
def withApp[A](op: Application => A): A =
|
||||
Play.maybeApplication map op err "Play application is not started!"
|
||||
op(old.play.Env.application)
|
||||
|
||||
// def system = withApp { implicit app =>
|
||||
// old.play.api.libs.concurrent.Akka.system
|
||||
// }
|
||||
|
||||
lazy val langs = loadConfig.getStringList("play.i18n.langs").map(Lang.apply)(scala.collection.breakOut)
|
||||
lazy val langs = loadConfig.getStringList("play.i18n.langs").asScala.map(Lang.apply)(scala.collection.breakOut)
|
||||
|
||||
private def enableScheduler = !(loadConfig getBoolean "app.scheduler.disabled")
|
||||
|
||||
|
@ -47,5 +47,5 @@ object PlayApp {
|
|||
lazy val isProd = isMode(_.Prod) && !loadConfig.getBoolean("forcedev")
|
||||
def isServer = !isTest
|
||||
|
||||
def isMode(f: Mode.type => Mode.Mode) = withApp { _.mode == f(Mode) }
|
||||
def isMode(f: Mode.type => Mode) = withApp { _.mode == f(Mode) }
|
||||
}
|
||||
|
|
|
@ -23,6 +23,6 @@ object Env {
|
|||
config = lila.common.PlayApp loadConfig "event",
|
||||
db = lila.db.Env.current,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -44,6 +44,6 @@ object Env {
|
|||
lazy val current = "explorer" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "explorer",
|
||||
gameColl = lila.game.Env.current.gameColl,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -127,14 +127,14 @@ final class Env(
|
|||
object Env {
|
||||
|
||||
lazy val current: Env = "fishnet" boot new Env(
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
uciMemo = lila.game.Env.current.uciMemo,
|
||||
requesterApi = lila.analyse.Env.current.requesterApi,
|
||||
hub = lila.hub.Env.current,
|
||||
db = lila.db.Env.current,
|
||||
config = lila.common.PlayApp loadConfig "fishnet",
|
||||
scheduler = lila.common.PlayApp.scheduler,
|
||||
bus = lila.common.PlayApp.system.lilaBus,
|
||||
bus = old.play.Env.actorSystem.lilaBus,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
sink = lila.analyse.Env.current.analyser
|
||||
)
|
||||
|
|
|
@ -31,7 +31,7 @@ final class Env(
|
|||
val CollectionCateg = config getString "collection.categ"
|
||||
val CollectionTopic = config getString "collection.topic"
|
||||
val CollectionPost = config getString "collection.post"
|
||||
import scala.collection.JavaConversions._
|
||||
import scala.collection.JavaConverters._
|
||||
val PublicCategIds = (config getStringList "public_categ_ids").toList
|
||||
}
|
||||
import settings._
|
||||
|
@ -93,6 +93,6 @@ object Env {
|
|||
notifyApi = lila.notify.Env.current.api,
|
||||
relationApi = lila.relation.Env.current.api,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -53,6 +53,6 @@ object Env {
|
|||
config = lila.common.PlayApp loadConfig "forumSearch",
|
||||
postApi = lila.forum.Env.current.postApi,
|
||||
makeClient = lila.search.Env.current.makeClient,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ object Env {
|
|||
config = lila.common.PlayApp loadConfig "game",
|
||||
db = lila.db.Env.current,
|
||||
mongoCache = lila.memo.Env.current.mongoCache,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
hub = lila.hub.Env.current,
|
||||
getLightUser = lila.user.Env.current.lightUserSync,
|
||||
appPath = play.api.Play.current.path.getCanonicalPath,
|
||||
|
|
|
@ -394,7 +394,7 @@ object GameRepo {
|
|||
)),
|
||||
UnwindField(F.playerUids),
|
||||
Match($doc(F.playerUids -> $doc("$ne" -> userId))),
|
||||
GroupField(F.playerUids)("gs" -> SumValue(1)),
|
||||
GroupField(F.playerUids)("gs" -> SumAll),
|
||||
Sort(Descending("gs")),
|
||||
Limit(limit)
|
||||
), ReadPreference.secondaryPreferred).map(_.firstBatch.flatMap { obj =>
|
||||
|
|
|
@ -3,6 +3,7 @@ package lila.game
|
|||
import akka.actor._
|
||||
import play.api.libs.iteratee._
|
||||
import play.api.libs.json._
|
||||
import play.api.libs.json.JodaWrites._
|
||||
|
||||
import actorApi.{ StartGame, FinishGame }
|
||||
import chess.format.FEN
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package lila.game
|
||||
|
||||
import play.api.libs.json._
|
||||
import play.api.libs.json.JodaWrites._
|
||||
|
||||
import chess.format.Forsyth
|
||||
import chess.variant.Crazyhouse
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package lila.game
|
||||
|
||||
import play.api.libs.iteratee._
|
||||
import play.api.libs.ws.WS
|
||||
import play.api.Play.current
|
||||
import old.play.api.libs.ws.WS
|
||||
|
||||
import chess.format.{ Forsyth, FEN }
|
||||
|
||||
|
@ -33,7 +32,7 @@ final class PngExport(url: String, size: Int) {
|
|||
orientation.map { "orientation" -> _.name }
|
||||
).flatten
|
||||
|
||||
WS.url(url).withQueryString(queryString: _*).getStream() flatMap {
|
||||
WS.url(url).withQueryString(queryString: _*).withMethod("GET").stream() flatMap {
|
||||
case (res, body) if res.status != 200 =>
|
||||
logger.warn(s"PgnExport $logHint ${fen.value} ${res.status}")
|
||||
fufail(res.status.toString)
|
||||
|
|
|
@ -51,7 +51,7 @@ object Env {
|
|||
|
||||
lazy val current = "gameSearch" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "gameSearch",
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
makeClient = lila.search.Env.current.makeClient
|
||||
)
|
||||
}
|
||||
|
|
|
@ -50,6 +50,6 @@ object Env {
|
|||
|
||||
lazy val current = "hub" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "hub",
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ object Env {
|
|||
|
||||
lazy val current = "importer" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "importer",
|
||||
scheduler = lila.common.PlayApp.system.scheduler,
|
||||
scheduler = old.play.Env.actorSystem.scheduler,
|
||||
roundMap = lila.round.Env.current.roundMap
|
||||
)
|
||||
}
|
||||
|
|
|
@ -73,12 +73,12 @@ private final class AggregationPipeline {
|
|||
List(dimensionGrouping(d) match {
|
||||
case Grouping.Group => Group(dimensionGroupId(d))(
|
||||
"v" -> f,
|
||||
"nb" -> SumValue(1),
|
||||
"nb" -> SumAll,
|
||||
"ids" -> AddFieldToSet("_id")
|
||||
)
|
||||
case Grouping.BucketAuto(buckets, granularity) => BucketAuto(dimensionGroupId(d), buckets, granularity)(
|
||||
"v" -> f,
|
||||
"nb" -> SumValue(1),
|
||||
"nb" -> SumAll,
|
||||
"ids" -> AddFieldToSet("_id") // AddFieldToSet crashes mongodb 3.4.1 server
|
||||
)
|
||||
}) map { Option(_) }
|
||||
|
@ -87,7 +87,7 @@ private final class AggregationPipeline {
|
|||
(dimensionGrouping(d) match {
|
||||
case Grouping.Group => List[PipelineOperator](
|
||||
Group($doc("dimension" -> dimensionGroupId(d), "metric" -> s"$$$metricDbKey"))(
|
||||
"v" -> SumValue(1),
|
||||
"v" -> SumAll,
|
||||
"ids" -> AddFieldToSet("_id")
|
||||
),
|
||||
regroupStacked,
|
||||
|
@ -102,7 +102,7 @@ private final class AggregationPipeline {
|
|||
),
|
||||
UnwindField("doc"),
|
||||
Group($doc("dimension" -> "$_id", "metric" -> "$doc.metric"))(
|
||||
"v" -> SumValue(1),
|
||||
"v" -> SumAll,
|
||||
"ids" -> AddFieldToSet("doc.id")
|
||||
),
|
||||
regroupStacked,
|
||||
|
@ -176,7 +176,7 @@ private final class AggregationPipeline {
|
|||
matchMoves(),
|
||||
sampleMoves
|
||||
) :::
|
||||
group(dimension, SumValue(1)) :::
|
||||
group(dimension, SumAll) :::
|
||||
List(
|
||||
Project($doc(
|
||||
"v" -> true,
|
||||
|
|
|
@ -57,7 +57,7 @@ object Env {
|
|||
config = lila.common.PlayApp loadConfig "insight",
|
||||
getPref = lila.pref.Env.current.api.getPrefById,
|
||||
areFriends = lila.relation.Env.current.api.fetchAreFriends,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
lifecycle = lila.common.PlayApp.lifecycle
|
||||
)
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ private final class Storage(coll: Coll) {
|
|||
|
||||
def nbByPerf(userId: String): Fu[Map[PerfType, Int]] = coll.aggregate(
|
||||
Match(BSONDocument(F.userId -> userId)),
|
||||
List(GroupField(F.perf)("nb" -> SumValue(1)))
|
||||
List(GroupField(F.perf)("nb" -> SumAll))
|
||||
).map {
|
||||
_.firstBatch.flatMap { doc =>
|
||||
for {
|
||||
|
|
|
@ -55,6 +55,6 @@ object Env {
|
|||
notifyApi = lila.notify.Env.current.api,
|
||||
userCache = lila.user.Env.current.cached,
|
||||
scheduler = lila.common.PlayApp.scheduler,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -91,7 +91,7 @@ object Env {
|
|||
gameCache = lila.game.Env.current.cached,
|
||||
poolApi = lila.pool.Env.current.api,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
scheduler = lila.common.PlayApp.scheduler
|
||||
)
|
||||
}
|
||||
|
|
|
@ -23,6 +23,6 @@ object Env {
|
|||
lazy val current = "memo" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "memo",
|
||||
db = lila.db.Env.current,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -18,6 +18,10 @@ final class MongoCache[K, V: MongoCache.Handler] private (
|
|||
keyToString: K => String
|
||||
) {
|
||||
|
||||
private case class Entry(_id: String, v: V, e: DateTime)
|
||||
|
||||
private implicit val entryBSONHandler = Macros.handler[Entry]
|
||||
|
||||
def apply(k: K): Fu[V] = cache.get(k, k =>
|
||||
coll.find($id(makeKey(k))).uno[Entry] flatMap {
|
||||
case None => f(k) flatMap { v =>
|
||||
|
@ -34,10 +38,6 @@ final class MongoCache[K, V: MongoCache.Handler] private (
|
|||
}
|
||||
}
|
||||
|
||||
private case class Entry(_id: String, v: V, e: DateTime)
|
||||
|
||||
private implicit val entryBSONHandler = Macros.handler[Entry]
|
||||
|
||||
private def makeKey(k: K) = s"$prefix:${keyToString(k)}"
|
||||
|
||||
private def persist(k: K, v: V): Funit = {
|
||||
|
|
|
@ -57,7 +57,7 @@ object Env {
|
|||
blocks = lila.relation.Env.current.api.fetchBlocks,
|
||||
follows = lila.relation.Env.current.api.fetchFollows,
|
||||
getPref = lila.pref.Env.current.api.getPref,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
isOnline = lila.user.Env.current.isOnline,
|
||||
lightUser = lila.user.Env.current.lightUserSync
|
||||
)
|
||||
|
|
|
@ -131,7 +131,7 @@ object Env {
|
|||
config = lila.common.PlayApp loadConfig "mod",
|
||||
db = lila.db.Env.current,
|
||||
hub = lila.hub.Env.current,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
scheduler = lila.common.PlayApp.scheduler,
|
||||
firewall = lila.security.Env.current.firewall,
|
||||
reportApi = lila.report.Env.current.api,
|
||||
|
|
|
@ -88,7 +88,7 @@ final class Gamify(
|
|||
"date" -> dateRange(after, before),
|
||||
"mod" -> notLichess
|
||||
)), List(
|
||||
GroupField("mod")("nb" -> SumValue(1)),
|
||||
GroupField("mod")("nb" -> SumAll),
|
||||
Sort(Descending("nb"))
|
||||
)).map {
|
||||
_.firstBatch.flatMap { obj =>
|
||||
|
@ -102,7 +102,7 @@ final class Gamify(
|
|||
"createdAt" -> dateRange(after, before),
|
||||
"processedBy" -> notLichess
|
||||
)), List(
|
||||
GroupField("processedBy")("nb" -> SumValue(1)),
|
||||
GroupField("processedBy")("nb" -> SumAll),
|
||||
Sort(Descending("nb"))
|
||||
)
|
||||
).map {
|
||||
|
|
|
@ -50,7 +50,7 @@ object Env {
|
|||
config = lila.common.PlayApp loadConfig "notify",
|
||||
getLightUser = lila.user.Env.current.lightUserSync,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ object Env {
|
|||
|
||||
lazy val current: Env = "perfStat" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "perfStat",
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
lightUser = lila.user.Env.current.lightUserSync,
|
||||
db = lila.db.Env.current
|
||||
)
|
||||
|
|
|
@ -71,7 +71,7 @@ object Env {
|
|||
hub = lila.hub.Env.current,
|
||||
notifyApi = lila.notify.Env.current.api,
|
||||
lightUserApi = lila.user.Env.current.lightUserApi,
|
||||
bus = lila.common.PlayApp.system.lilaBus,
|
||||
bus = old.play.Env.actorSystem.lilaBus,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
scheduler = lila.common.PlayApp.scheduler
|
||||
)
|
||||
|
|
|
@ -35,7 +35,7 @@ object Env {
|
|||
lazy val current: Env = "pool" boot new Env(
|
||||
lobbyActor = lila.hub.Env.current.actor.lobby,
|
||||
playbanApi = lila.playban.Env.current.api,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
onStart = lila.game.Env.current.onStart
|
||||
)
|
||||
}
|
||||
|
|
|
@ -41,6 +41,6 @@ object Env {
|
|||
studyApi = lila.study.Env.current.api,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
db = lila.db.Env.current,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -61,7 +61,7 @@ object Env {
|
|||
|
||||
lazy val current: Env = "push" boot new Env(
|
||||
db = lila.db.Env.current,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
getLightUser = lila.user.Env.current.lightUserSync,
|
||||
roundSocketHub = lila.hub.Env.current.socket.round,
|
||||
scheduler = lila.common.PlayApp.scheduler,
|
||||
|
|
|
@ -88,7 +88,7 @@ object Env {
|
|||
renderer = lila.hub.Env.current.actor.renderer,
|
||||
lightUserApi = lila.user.Env.current.lightUserApi,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
lifecycle = lila.common.PlayApp.lifecycle
|
||||
)
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ object Env {
|
|||
onlineUserIds = lila.user.Env.current.onlineUserIdMemo,
|
||||
lightUserApi = lila.user.Env.current.lightUserApi,
|
||||
followable = lila.pref.Env.current.api.followable _,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
scheduler = lila.common.PlayApp.scheduler
|
||||
)
|
||||
|
|
|
@ -67,7 +67,7 @@ object Env {
|
|||
isOnline = lila.user.Env.current.isOnline,
|
||||
noteApi = lila.user.Env.current.noteApi,
|
||||
securityApi = lila.security.Env.current.api,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
hub = lila.hub.Env.current,
|
||||
asyncCache = lila.memo.Env.current.asyncCache
|
||||
)
|
||||
|
|
|
@ -282,7 +282,7 @@ final class ReportApi(
|
|||
coll.aggregate(
|
||||
Match(unprocessedSelect),
|
||||
List(
|
||||
GroupField("room")("nb" -> SumValue(1))
|
||||
GroupField("room")("nb" -> SumAll)
|
||||
)
|
||||
).map { res =>
|
||||
Room.Counts(res.firstBatch.flatMap { doc =>
|
||||
|
|
|
@ -241,7 +241,7 @@ object Env {
|
|||
|
||||
lazy val current = "round" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "round",
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
db = lila.db.Env.current,
|
||||
hub = lila.hub.Env.current,
|
||||
fishnetPlayer = lila.fishnet.Env.current.player,
|
||||
|
|
|
@ -22,7 +22,7 @@ object Env {
|
|||
|
||||
lazy val current = "search" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "search",
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
scheduler = lila.common.PlayApp.scheduler
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package lila.security
|
||||
|
||||
import play.api.libs.ws.WS
|
||||
import play.api.Play.current
|
||||
import old.play.api.libs.ws.WS
|
||||
|
||||
final class DisposableEmailDomain(
|
||||
providerUrl: String,
|
||||
|
|
|
@ -145,7 +145,7 @@ object Env {
|
|||
lazy val current = "security" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "security",
|
||||
db = lila.db.Env.current,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
scheduler = lila.common.PlayApp.scheduler,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
captcher = lila.hub.Env.current.actor.captcher
|
||||
|
|
|
@ -4,7 +4,8 @@ import scala.concurrent.duration._
|
|||
|
||||
import akka.actor.ActorSystem
|
||||
import play.api.i18n.Lang
|
||||
import play.api.libs.ws.{ WS, WSAuthScheme }
|
||||
import old.play.api.libs.ws.WS
|
||||
import play.api.libs.ws.WSAuthScheme
|
||||
import play.api.Play.current
|
||||
import play.twirl.api.Html
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
package lila.security
|
||||
|
||||
import play.api.libs.ws.WS
|
||||
import old.play.api.libs.ws.WS
|
||||
import play.api.mvc.RequestHeader
|
||||
import play.api.Play.current
|
||||
|
||||
import lila.common.PimpedJson._
|
||||
|
||||
|
|
|
@ -2,8 +2,7 @@ package lila.security
|
|||
|
||||
import lila.common.IpAddress
|
||||
|
||||
import play.api.libs.ws.WS
|
||||
import play.api.Play.current
|
||||
import old.play.api.libs.ws.WS
|
||||
|
||||
final class Tor(providerUrl: String) {
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ object UserSpy {
|
|||
case class IPData(ip: IpAddress, blocked: Boolean, location: Location)
|
||||
|
||||
private[security] def apply(firewall: Firewall, geoIP: GeoIP)(coll: Coll)(userId: String): Fu[UserSpy] = for {
|
||||
user ← UserRepo named userId flatten "[spy] user not found"
|
||||
user ← UserRepo named userId err "[spy] user not found"
|
||||
infos ← Store.findInfoByUser(user.id)
|
||||
ips = infos.map(_.ip).distinct
|
||||
blockedIps ← (ips map firewall.blocksIp).sequenceFu
|
||||
|
|
|
@ -52,6 +52,6 @@ object Env {
|
|||
prefApi = lila.pref.Env.current.api,
|
||||
relationApi = lila.relation.Env.current.api,
|
||||
gameCache = lila.game.Env.current.cached,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ object Env {
|
|||
lazy val current: Env = "shutup" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "shutup",
|
||||
reporter = lila.hub.Env.current.actor.report,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
follows = lila.relation.Env.current.api.fetchFollows _,
|
||||
db = lila.db.Env.current
|
||||
)
|
||||
|
|
|
@ -125,7 +125,7 @@ object Env {
|
|||
|
||||
lazy val current = "simul" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "simul",
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
scheduler = lila.common.PlayApp.scheduler,
|
||||
db = lila.db.Env.current,
|
||||
hub = lila.hub.Env.current,
|
||||
|
|
|
@ -29,6 +29,6 @@ object Env {
|
|||
lazy val current = "site" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "site",
|
||||
hub = lila.hub.Env.current,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -41,7 +41,7 @@ final class Env(
|
|||
object Env {
|
||||
|
||||
lazy val current: Env = "slack" boot new Env(
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
getLightUser = lila.user.Env.current.lightUser,
|
||||
config = lila.common.PlayApp loadConfig "slack"
|
||||
)
|
||||
|
|
|
@ -36,7 +36,7 @@ object Env {
|
|||
|
||||
lazy val current = "socket" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "socket",
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
scheduler = lila.common.PlayApp.scheduler
|
||||
)
|
||||
}
|
||||
|
|
|
@ -158,7 +158,7 @@ object Env {
|
|||
notifyApi = lila.notify.Env.current.api,
|
||||
getPref = lila.pref.Env.current.api.getPref,
|
||||
getRelation = lila.relation.Env.current.api.fetchRelation,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
hub = lila.hub.Env.current,
|
||||
db = lila.db.Env.current,
|
||||
asyncCache = lila.memo.Env.current.asyncCache
|
||||
|
|
|
@ -67,6 +67,6 @@ object Env {
|
|||
config = lila.common.PlayApp loadConfig "studySearch",
|
||||
studyEnv = lila.study.Env.current,
|
||||
makeClient = lila.search.Env.current.makeClient,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ object Env {
|
|||
config = lila.common.PlayApp loadConfig "team",
|
||||
hub = lila.hub.Env.current,
|
||||
notifyApi = lila.notify.Env.current.api,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
db = lila.db.Env.current
|
||||
)
|
||||
|
|
|
@ -46,6 +46,6 @@ object Env {
|
|||
lazy val current = "teamSearch" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "teamSearch",
|
||||
makeClient = lila.search.Env.current.makeClient,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -64,6 +64,6 @@ object Env {
|
|||
lobbySocket = lila.hub.Env.current.socket.lobby,
|
||||
renderer = lila.hub.Env.current.actor.renderer,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ object Env {
|
|||
|
||||
lazy val current = "tournament" boot new Env(
|
||||
config = lila.common.PlayApp loadConfig "tournament",
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
db = lila.db.Env.current,
|
||||
mongoCache = lila.memo.Env.current.mongoCache,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
|
|
|
@ -34,7 +34,7 @@ final class LeaderboardApi(
|
|||
import reactivemongo.api.collections.bson.BSONBatchCommands.AggregationFramework._
|
||||
coll.aggregateWithReadPreference(
|
||||
Match($doc("u" -> user.id)),
|
||||
List(GroupField("v")("nb" -> SumValue(1), "points" -> PushField("s"), "ratios" -> PushField("w"))),
|
||||
List(GroupField("v")("nb" -> SumAll, "points" -> PushField("s"), "ratios" -> PushField("w"))),
|
||||
ReadPreference.secondaryPreferred
|
||||
).map {
|
||||
_.firstBatch map leaderboardAggregationResultBSONHandler.read
|
||||
|
|
|
@ -79,7 +79,7 @@ object PairingRepo {
|
|||
List(
|
||||
Project($doc("u" -> true, "_id" -> false)),
|
||||
UnwindField("u"),
|
||||
GroupField("u")("nb" -> SumValue(1))
|
||||
GroupField("u")("nb" -> SumAll)
|
||||
)
|
||||
).map {
|
||||
_.firstBatch.flatMap { doc =>
|
||||
|
@ -145,7 +145,7 @@ object PairingRepo {
|
|||
"b2" -> $doc("$cond" -> $arr("$b2", 1, 0))
|
||||
)),
|
||||
GroupField("w")(
|
||||
"games" -> SumValue(1),
|
||||
"games" -> SumAll,
|
||||
"moves" -> SumField("t"),
|
||||
"b1" -> SumField("b1"),
|
||||
"b2" -> SumField("b2")
|
||||
|
|
|
@ -94,7 +94,7 @@ object Env {
|
|||
db = lila.db.Env.current,
|
||||
hub = lila.hub.Env.current,
|
||||
lightUser = lila.user.Env.current.lightUserSync,
|
||||
system = lila.common.PlayApp.system,
|
||||
system = old.play.Env.actorSystem,
|
||||
scheduler = lila.common.PlayApp.scheduler,
|
||||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
isProd = lila.common.PlayApp.isProd
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package lila.tv
|
||||
|
||||
import com.typesafe.config.ConfigFactory
|
||||
import scala.collection.JavaConversions._
|
||||
import scala.collection.JavaConverters._
|
||||
import scala.util.{ Try, Success, Failure }
|
||||
|
||||
final class StreamerList(
|
||||
|
|
|
@ -97,6 +97,6 @@ object Env {
|
|||
asyncCache = lila.memo.Env.current.asyncCache,
|
||||
scheduler = lila.common.PlayApp.scheduler,
|
||||
timeline = lila.hub.Env.current.actor.timeline,
|
||||
system = lila.common.PlayApp.system
|
||||
system = old.play.Env.actorSystem
|
||||
)
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package lila.user
|
|||
import lila.common.PimpedJson._
|
||||
import lila.rating.{ Perf, PerfType }
|
||||
import play.api.libs.json._
|
||||
import play.api.libs.json.JodaWrites._
|
||||
import User.{ PlayTime, LightPerf }
|
||||
|
||||
final class JsonView(isOnline: String => Boolean) {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package lila.user
|
||||
|
||||
import org.joda.time.DateTime
|
||||
import reactivemongo.api.collections.bson.BSONBatchCommands.AggregationFramework.{ Match, Project, GroupField, SumValue }
|
||||
import reactivemongo.api.collections.bson.BSONBatchCommands.AggregationFramework.{ Match, Project, GroupField, SumAll }
|
||||
import reactivemongo.api.ReadPreference
|
||||
import reactivemongo.bson._
|
||||
import scala.concurrent.duration._
|
||||
|
@ -127,7 +127,7 @@ final class RankingApi(
|
|||
)
|
||||
)
|
||||
)),
|
||||
GroupField("r")("nb" -> SumValue(1))
|
||||
GroupField("r")("nb" -> SumAll)
|
||||
),
|
||||
ReadPreference.secondaryPreferred
|
||||
).map { res =>
|
||||
|
|
|
@ -188,7 +188,7 @@ private[video] final class VideoApi(
|
|||
|
||||
private val max = 25
|
||||
|
||||
import reactivemongo.api.collections.bson.BSONBatchCommands.AggregationFramework.{ Descending, GroupField, Match, Project, UnwindField, Sort, SumValue }
|
||||
import reactivemongo.api.collections.bson.BSONBatchCommands.AggregationFramework.{ Descending, GroupField, Match, Project, UnwindField, Sort, SumAll }
|
||||
|
||||
private val pathsCache = asyncCache.clearable[List[Tag], List[TagNb]](
|
||||
name = "video.paths",
|
||||
|
@ -200,7 +200,7 @@ private[video] final class VideoApi(
|
|||
else videoColl.aggregateWithReadPreference(
|
||||
Match($doc("tags" $all filterTags)),
|
||||
List(Project($doc("tags" -> true)), UnwindField("tags"),
|
||||
GroupField("tags")("nb" -> SumValue(1))),
|
||||
GroupField("tags")("nb" -> SumAll)),
|
||||
ReadPreference.secondaryPreferred
|
||||
).map(
|
||||
_.firstBatch.flatMap(_.asOpt[TagNb])
|
||||
|
@ -230,7 +230,7 @@ private[video] final class VideoApi(
|
|||
name = "video.popular",
|
||||
f = videoColl.aggregateWithReadPreference(
|
||||
Project($doc("tags" -> true)), List(
|
||||
UnwindField("tags"), GroupField("tags")("nb" -> SumValue(1)),
|
||||
UnwindField("tags"), GroupField("tags")("nb" -> SumAll),
|
||||
Sort(Descending("nb"))
|
||||
),
|
||||
readPreference = ReadPreference.secondaryPreferred
|
||||
|
|
|
@ -41,7 +41,7 @@ object BuildSettings {
|
|||
|
||||
val compilerOptions = Seq(
|
||||
"-deprecation", "-unchecked", "-feature", "-language:_",
|
||||
"-Xfatal-warnings",
|
||||
// "-Xfatal-warnings",
|
||||
"-Ywarn-dead-code",
|
||||
// "-Ywarn-unused-import",
|
||||
// "-Ywarn-unused",
|
||||
|
|
|
@ -52,7 +52,9 @@ object Dependencies {
|
|||
object play {
|
||||
val version = "2.6.3"
|
||||
val api = "com.typesafe.play" %% "play" % version
|
||||
val iteratee = "com.typesafe.play" %% "play-iteratees" % "2.6.1"
|
||||
val jodaForms = "com.typesafe.play" %% "play-joda-forms" % version
|
||||
val jodaJson = "com.typesafe.play" %% "play-json-joda" % version
|
||||
val test = "com.typesafe.play" %% "play-test" % version
|
||||
}
|
||||
object akka {
|
||||
|
|
Loading…
Reference in New Issue