done propagating the execution context everywhere
parent
74afc821e7
commit
c0aa9734f3
|
@ -81,7 +81,7 @@ final class Env(
|
||||||
val rating: lila.rating.Env,
|
val rating: lila.rating.Env,
|
||||||
val lilaCookie: lila.common.LilaCookie,
|
val lilaCookie: lila.common.LilaCookie,
|
||||||
val controllerComponents: ControllerComponents
|
val controllerComponents: ControllerComponents
|
||||||
)(implicit val system: ActorSystem) {
|
)(implicit val system: ActorSystem, val executionContext: ExecutionContext) {
|
||||||
|
|
||||||
val isProd = mode == Mode.Prod
|
val isProd = mode == Mode.Prod
|
||||||
val isDev = mode == Mode.Dev
|
val isDev = mode == Mode.Dev
|
||||||
|
|
|
@ -14,7 +14,7 @@ final class Analyse(
|
||||||
env: Env,
|
env: Env,
|
||||||
gameC: => Game,
|
gameC: => Game,
|
||||||
roundC: => Round
|
roundC: => Round
|
||||||
)(implicit ec: scala.concurrent.ExecutionContext)
|
)
|
||||||
extends LilaController(env) {
|
extends LilaController(env) {
|
||||||
|
|
||||||
def requestAnalysis(id: String) = Auth { implicit ctx => me =>
|
def requestAnalysis(id: String) = Auth { implicit ctx => me =>
|
||||||
|
|
|
@ -7,7 +7,7 @@ import lila.api.Context
|
||||||
import lila.app._
|
import lila.app._
|
||||||
import views._
|
import views._
|
||||||
|
|
||||||
final class KeyPages(env: Env) {
|
final class KeyPages(env: Env)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def home(status: Results.Status)(implicit ctx: Context): Fu[Result] =
|
def home(status: Results.Status)(implicit ctx: Context): Fu[Result] =
|
||||||
env
|
env
|
||||||
|
|
|
@ -24,8 +24,8 @@ abstract private[controllers] class LilaController(val env: Env)
|
||||||
with ResponseWriter {
|
with ResponseWriter {
|
||||||
|
|
||||||
val controllerComponents = env.controllerComponents
|
val controllerComponents = env.controllerComponents
|
||||||
|
implicit val executionContext = env.executionContext
|
||||||
implicit val executionContext = defaultExecutionContext
|
implicit val scheduler = env.scheduler
|
||||||
|
|
||||||
implicit protected val LilaResultZero = Zero.instance[Result](Results.NotFound)
|
implicit protected val LilaResultZero = Zero.instance[Result](Results.NotFound)
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import lila.app._
|
||||||
|
|
||||||
final class Prismic(
|
final class Prismic(
|
||||||
env: Env
|
env: Env
|
||||||
)(implicit ws: play.api.libs.ws.WSClient) {
|
)(implicit ec: scala.concurrent.ExecutionContext, ws: play.api.libs.ws.WSClient) {
|
||||||
|
|
||||||
private val logger = lila.log("prismic")
|
private val logger = lila.log("prismic")
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ final class UserAnalysis(
|
||||||
forecasts => {
|
forecasts => {
|
||||||
val wait = 50 + (Forecast maxPlies forecasts min 10) * 50
|
val wait = 50 + (Forecast maxPlies forecasts min 10) * 50
|
||||||
env.round.forecastApi.playAndSave(pov, uci, forecasts) >>
|
env.round.forecastApi.playAndSave(pov, uci, forecasts) >>
|
||||||
lila.common.Future.sleep(wait.millis)(env.scheduler) inject
|
lila.common.Future.sleep(wait.millis) inject
|
||||||
Ok(Json.obj("reload" -> true))
|
Ok(Json.obj("reload" -> true))
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,7 +18,7 @@ final class ErrorHandler(
|
||||||
router: => Option[Router],
|
router: => Option[Router],
|
||||||
mainC: => controllers.Main,
|
mainC: => controllers.Main,
|
||||||
lobbyC: => controllers.Lobby
|
lobbyC: => controllers.Lobby
|
||||||
) extends DefaultHttpErrorHandler(environment, config, sourceMapper, router) {
|
)(implicit ec: scala.concurrent.ExecutionContext) extends DefaultHttpErrorHandler(environment, config, sourceMapper, router) {
|
||||||
|
|
||||||
override def onProdServerError(req: RequestHeader, exception: UsefulException) =
|
override def onProdServerError(req: RequestHeader, exception: UsefulException) =
|
||||||
Future {
|
Future {
|
||||||
|
|
|
@ -87,7 +87,7 @@ object GameFilterMenu {
|
||||||
pag: lila.game.PaginatorBuilder,
|
pag: lila.game.PaginatorBuilder,
|
||||||
gameRepo: lila.game.GameRepo,
|
gameRepo: lila.game.GameRepo,
|
||||||
bookmarkApi: lila.bookmark.BookmarkApi
|
bookmarkApi: lila.bookmark.BookmarkApi
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def apply(
|
def apply(
|
||||||
user: User,
|
user: User,
|
||||||
|
|
|
@ -29,7 +29,7 @@ final class Preload(
|
||||||
roundProxy: lila.round.GameProxyRepo,
|
roundProxy: lila.round.GameProxyRepo,
|
||||||
simulIsFeaturable: Simul => Boolean,
|
simulIsFeaturable: Simul => Boolean,
|
||||||
lastPostCache: lila.blog.LastPostCache
|
lastPostCache: lila.blog.LastPostCache
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import Preload._
|
import Preload._
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ final class TeamInfoApi(
|
||||||
teamCached: lila.team.Cached,
|
teamCached: lila.team.Cached,
|
||||||
tournamentRepo: TournamentRepo,
|
tournamentRepo: TournamentRepo,
|
||||||
requestRepo: RequestRepo
|
requestRepo: RequestRepo
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def apply(team: Team, me: Option[User]): Fu[TeamInfo] =
|
def apply(team: Team, me: Option[User]): Fu[TeamInfo] =
|
||||||
for {
|
for {
|
||||||
|
|
|
@ -61,7 +61,7 @@ object UserInfo {
|
||||||
relationApi: RelationApi,
|
relationApi: RelationApi,
|
||||||
noteApi: lila.user.NoteApi,
|
noteApi: lila.user.NoteApi,
|
||||||
prefApi: lila.pref.PrefApi
|
prefApi: lila.pref.PrefApi
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
def apply(u: User, ctx: Context): Fu[Social] =
|
def apply(u: User, ctx: Context): Fu[Social] =
|
||||||
ctx.userId.?? { relationApi.fetchRelation(_, u.id) } zip
|
ctx.userId.?? { relationApi.fetchRelation(_, u.id) } zip
|
||||||
ctx.me.?? { me =>
|
ctx.me.?? { me =>
|
||||||
|
@ -87,10 +87,10 @@ object UserInfo {
|
||||||
bookmarkApi: BookmarkApi,
|
bookmarkApi: BookmarkApi,
|
||||||
gameCached: lila.game.Cached,
|
gameCached: lila.game.Cached,
|
||||||
crosstableApi: lila.game.CrosstableApi
|
crosstableApi: lila.game.CrosstableApi
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
def apply(u: User, ctx: Context): Fu[NbGames] =
|
def apply(u: User, ctx: Context): Fu[NbGames] =
|
||||||
(ctx.me.filter(u !=) ?? { me =>
|
(ctx.me.filter(u !=) ?? { me =>
|
||||||
crosstableApi.withMatchup(me.id, u.id) map some
|
crosstableApi.withMatchup(me.id, u.id) dmap some
|
||||||
}) zip
|
}) zip
|
||||||
gameCached.nbPlaying(u.id) zip
|
gameCached.nbPlaying(u.id) zip
|
||||||
gameCached.nbImportedBy(u.id) zip
|
gameCached.nbImportedBy(u.id) zip
|
||||||
|
@ -121,11 +121,11 @@ object UserInfo {
|
||||||
insightShare: lila.insight.Share,
|
insightShare: lila.insight.Share,
|
||||||
playTimeApi: lila.game.PlayTimeApi,
|
playTimeApi: lila.game.PlayTimeApi,
|
||||||
playbanApi: lila.playban.PlaybanApi
|
playbanApi: lila.playban.PlaybanApi
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
def apply(user: User, nbs: NbGames, ctx: Context): Fu[UserInfo] =
|
def apply(user: User, nbs: NbGames, ctx: Context): Fu[UserInfo] =
|
||||||
(ctx.noBlind ?? ratingChartApi(user)) zip
|
(ctx.noBlind ?? ratingChartApi(user)) zip
|
||||||
relationApi.countFollowers(user.id) zip
|
relationApi.countFollowers(user.id) zip
|
||||||
(ctx.me ?? Granter(_.UserSpy) ?? { relationApi.countBlockers(user.id) map (_.some) }) zip
|
(ctx.me ?? Granter(_.UserSpy) ?? { relationApi.countBlockers(user.id) dmap some }) zip
|
||||||
postApi.nbByUser(user.id) zip
|
postApi.nbByUser(user.id) zip
|
||||||
studyRepo.countByOwner(user.id) zip
|
studyRepo.countByOwner(user.id) zip
|
||||||
trophyApi.findByUser(user) zip
|
trophyApi.findByUser(user) zip
|
||||||
|
|
|
@ -15,7 +15,7 @@ final class ActivityReadApi(
|
||||||
simulApi: lila.simul.SimulApi,
|
simulApi: lila.simul.SimulApi,
|
||||||
studyApi: lila.study.StudyApi,
|
studyApi: lila.study.StudyApi,
|
||||||
tourLeaderApi: lila.tournament.LeaderboardApi
|
tourLeaderApi: lila.tournament.LeaderboardApi
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import BSONHandlers._
|
import BSONHandlers._
|
||||||
import model._
|
import model._
|
||||||
|
|
|
@ -8,7 +8,7 @@ import lila.user.User
|
||||||
final class ActivityWriteApi(
|
final class ActivityWriteApi(
|
||||||
coll: Coll,
|
coll: Coll,
|
||||||
studyApi: lila.study.StudyApi
|
studyApi: lila.study.StudyApi
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import Activity._
|
import Activity._
|
||||||
import BSONHandlers._
|
import BSONHandlers._
|
||||||
|
|
|
@ -17,7 +17,7 @@ final class Env(
|
||||||
tourLeaderApi: lila.tournament.LeaderboardApi,
|
tourLeaderApi: lila.tournament.LeaderboardApi,
|
||||||
getTourName: lila.tournament.GetTourName,
|
getTourName: lila.tournament.GetTourName,
|
||||||
getTeamName: lila.team.GetTeamName
|
getTeamName: lila.team.GetTeamName
|
||||||
)(implicit system: ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem) {
|
||||||
|
|
||||||
private lazy val coll = db(CollName("activity"))
|
private lazy val coll = db(CollName("activity"))
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,11 @@ final private[api] class Cli(
|
||||||
coach: lila.coach.Env,
|
coach: lila.coach.Env,
|
||||||
evalCache: lila.evalCache.Env,
|
evalCache: lila.evalCache.Env,
|
||||||
plan: lila.plan.Env
|
plan: lila.plan.Env
|
||||||
) extends lila.common.Cli {
|
)(implicit ec: scala.concurrent.ExecutionContext) extends lila.common.Cli {
|
||||||
|
|
||||||
private val logger = lila.log("cli")
|
private val logger = lila.log("cli")
|
||||||
|
|
||||||
def apply(args: List[String]): Fu[String] = run(args).map(_ + "\n") ~ {
|
def apply(args: List[String]): Fu[String] = run(args).dmap(_ + "\n") ~ {
|
||||||
_.logFailure(logger, _ => args mkString " ") foreach { output =>
|
_.logFailure(logger, _ => args mkString " ") foreach { output =>
|
||||||
logger.info("%s\n%s".format(args mkString " ", output))
|
logger.info("%s\n%s".format(args mkString " ", output))
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ final class Env(
|
||||||
lifecycle: ApplicationLifecycle,
|
lifecycle: ApplicationLifecycle,
|
||||||
ws: WSClient,
|
ws: WSClient,
|
||||||
val mode: Mode
|
val mode: Mode
|
||||||
)(implicit system: ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem) {
|
||||||
|
|
||||||
val config = ApiConfig loadFrom appConfig
|
val config = ApiConfig loadFrom appConfig
|
||||||
import config.apiToken
|
import config.apiToken
|
||||||
|
|
|
@ -15,7 +15,7 @@ final class EventStream(
|
||||||
challengeJsonView: lila.challenge.JsonView,
|
challengeJsonView: lila.challenge.JsonView,
|
||||||
challengeMaker: lila.challenge.ChallengeMaker,
|
challengeMaker: lila.challenge.ChallengeMaker,
|
||||||
onlineBots: lila.bot.OnlineBots
|
onlineBots: lila.bot.OnlineBots
|
||||||
)(implicit system: ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem) {
|
||||||
|
|
||||||
private case object SetOnline
|
private case object SetOnline
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ final private[api] class GameApi(
|
||||||
gameCache: lila.game.Cached,
|
gameCache: lila.game.Cached,
|
||||||
analysisRepo: lila.analyse.AnalysisRepo,
|
analysisRepo: lila.analyse.AnalysisRepo,
|
||||||
crosstableApi: CrosstableApi
|
crosstableApi: CrosstableApi
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import GameApi.WithFlags
|
import GameApi.WithFlags
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,7 @@ final class GameApiV2(
|
||||||
pairingRepo: lila.tournament.PairingRepo,
|
pairingRepo: lila.tournament.PairingRepo,
|
||||||
analysisRepo: lila.analyse.AnalysisRepo,
|
analysisRepo: lila.analyse.AnalysisRepo,
|
||||||
getLightUser: LightUser.Getter
|
getLightUser: LightUser.Getter
|
||||||
)(implicit system: akka.actor.ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: akka.actor.ActorSystem) {
|
||||||
|
|
||||||
import GameApiV2._
|
import GameApiV2._
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ final class GameApiV2(
|
||||||
enrich(config.flags)(game) flatMap {
|
enrich(config.flags)(game) flatMap {
|
||||||
case (game, initialFen, analysis) =>
|
case (game, initialFen, analysis) =>
|
||||||
config.format match {
|
config.format match {
|
||||||
case Format.JSON => toJson(game, initialFen, analysis, config.flags) map Json.stringify
|
case Format.JSON => toJson(game, initialFen, analysis, config.flags) dmap Json.stringify
|
||||||
case Format.PGN => pgnDump.toPgnString(game, initialFen, analysis, config.flags)
|
case Format.PGN => pgnDump.toPgnString(game, initialFen, analysis, config.flags)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ final class GameApiV2(
|
||||||
|
|
||||||
private def enrich(flags: WithFlags)(game: Game) =
|
private def enrich(flags: WithFlags)(game: Game) =
|
||||||
gameRepo initialFen game flatMap { initialFen =>
|
gameRepo initialFen game flatMap { initialFen =>
|
||||||
(flags.evals ?? analysisRepo.byGame(game)) map { analysis =>
|
(flags.evals ?? analysisRepo.byGame(game)) dmap { analysis =>
|
||||||
(game, initialFen, analysis)
|
(game, initialFen, analysis)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,7 +116,7 @@ final class GameApiV2(
|
||||||
|
|
||||||
private def jsonFormatter(flags: WithFlags) =
|
private def jsonFormatter(flags: WithFlags) =
|
||||||
(game: Game, initialFen: Option[FEN], analysis: Option[Analysis]) =>
|
(game: Game, initialFen: Option[FEN], analysis: Option[Analysis]) =>
|
||||||
toJson(game, initialFen, analysis, flags) map { json =>
|
toJson(game, initialFen, analysis, flags) dmap { json =>
|
||||||
s"${Json.stringify(json)}\n"
|
s"${Json.stringify(json)}\n"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@ final private class InfluxEvent(
|
||||||
event("lila_start", s"Lila starts: $seed")
|
event("lila_start", s"Lila starts: $seed")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
implicit def ec = context.dispatcher
|
||||||
|
|
||||||
def receive = {
|
def receive = {
|
||||||
case DeployPre => event("lila_deploy_pre", "Lila will soon restart")
|
case DeployPre => event("lila_deploy_pre", "Lila will soon restart")
|
||||||
case DeployPost => event("lila_deploy_post", "Lila restarts for deploy now")
|
case DeployPost => event("lila_deploy_post", "Lila restarts for deploy now")
|
||||||
|
|
|
@ -14,7 +14,7 @@ final class LobbyApi(
|
||||||
seekApi: SeekApi,
|
seekApi: SeekApi,
|
||||||
pools: List[lila.pool.PoolConfig],
|
pools: List[lila.pool.PoolConfig],
|
||||||
gameProxyRepo: lila.round.GameProxyRepo
|
gameProxyRepo: lila.round.GameProxyRepo
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
val poolsJson = Json toJson pools
|
val poolsJson = Json toJson pools
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ final class PgnDump(
|
||||||
annotator: Annotator,
|
annotator: Annotator,
|
||||||
simulApi: lila.simul.SimulApi,
|
simulApi: lila.simul.SimulApi,
|
||||||
getTournamentName: lila.tournament.GetTourName
|
getTournamentName: lila.tournament.GetTourName
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def apply(game: Game, initialFen: Option[FEN], analysis: Option[Analysis], flags: WithFlags): Fu[Pgn] =
|
def apply(game: Game, initialFen: Option[FEN], analysis: Option[Analysis], flags: WithFlags): Fu[Pgn] =
|
||||||
dumper(game, initialFen, flags) flatMap { pgn =>
|
dumper(game, initialFen, flags) flatMap { pgn =>
|
||||||
|
@ -48,7 +48,7 @@ final class PgnDump(
|
||||||
toPgnString(game, initialFen, analysis, flags)
|
toPgnString(game, initialFen, analysis, flags)
|
||||||
|
|
||||||
def toPgnString(game: Game, initialFen: Option[FEN], analysis: Option[Analysis], flags: WithFlags) =
|
def toPgnString(game: Game, initialFen: Option[FEN], analysis: Option[Analysis], flags: WithFlags) =
|
||||||
apply(game, initialFen, analysis, flags).map { pgn =>
|
apply(game, initialFen, analysis, flags) dmap { pgn =>
|
||||||
// merge analysis & eval comments
|
// merge analysis & eval comments
|
||||||
// 1. e4 { [%eval 0.17] } { [%clk 0:00:30] }
|
// 1. e4 { [%eval 0.17] } { [%clk 0:00:30] }
|
||||||
// 1. e4 { [%eval 0.17] [%clk 0:00:30] }
|
// 1. e4 { [%eval 0.17] [%clk 0:00:30] }
|
||||||
|
|
|
@ -23,7 +23,7 @@ final private[api] class RoundApi(
|
||||||
gameRepo: lila.game.GameRepo,
|
gameRepo: lila.game.GameRepo,
|
||||||
tourApi: lila.tournament.TournamentApi,
|
tourApi: lila.tournament.TournamentApi,
|
||||||
simulApi: lila.simul.SimulApi
|
simulApi: lila.simul.SimulApi
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def player(pov: Pov, apiVersion: ApiVersion)(implicit ctx: Context): Fu[JsObject] =
|
def player(pov: Pov, apiVersion: ApiVersion)(implicit ctx: Context): Fu[JsObject] =
|
||||||
gameRepo
|
gameRepo
|
||||||
|
|
|
@ -19,7 +19,7 @@ final private[api] class UserApi(
|
||||||
onlineDoing: lila.relation.OnlineDoing,
|
onlineDoing: lila.relation.OnlineDoing,
|
||||||
gameProxyRepo: lila.round.GameProxyRepo,
|
gameProxyRepo: lila.round.GameProxyRepo,
|
||||||
net: NetConfig
|
net: NetConfig
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def pagerJson(pag: Paginator[User]): JsObject =
|
def pagerJson(pag: Paginator[User]): JsObject =
|
||||||
Json.obj("paginator" -> PaginatorJson(pag mapResults one))
|
Json.obj("paginator" -> PaginatorJson(pag mapResults one))
|
||||||
|
@ -29,7 +29,7 @@ final private[api] class UserApi(
|
||||||
Json.obj("url" -> makeUrl(s"@/${u.username}")) // for app BC
|
Json.obj("url" -> makeUrl(s"@/${u.username}")) // for app BC
|
||||||
|
|
||||||
def extended(username: String, as: Option[User]): Fu[Option[JsObject]] = userRepo named username flatMap {
|
def extended(username: String, as: Option[User]): Fu[Option[JsObject]] = userRepo named username flatMap {
|
||||||
_ ?? { extended(_, as) map some }
|
_ ?? { extended(_, as) dmap some }
|
||||||
}
|
}
|
||||||
|
|
||||||
def extended(u: User, as: Option[User]): Fu[JsObject] =
|
def extended(u: User, as: Option[User]): Fu[JsObject] =
|
||||||
|
@ -40,7 +40,7 @@ final private[api] class UserApi(
|
||||||
"closed" -> true
|
"closed" -> true
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
gameProxyRepo.urgentGames(u).map(_.headOption) zip
|
gameProxyRepo.urgentGames(u).dmap(_.headOption) zip
|
||||||
(as.filter(u !=) ?? { me =>
|
(as.filter(u !=) ?? { me =>
|
||||||
crosstableApi.nbGames(me.id, u.id)
|
crosstableApi.nbGames(me.id, u.id)
|
||||||
}) zip
|
}) zip
|
||||||
|
|
|
@ -13,7 +13,7 @@ final class UserGameApi(
|
||||||
bookmarkApi: lila.bookmark.BookmarkApi,
|
bookmarkApi: lila.bookmark.BookmarkApi,
|
||||||
lightUser: lila.user.LightUserApi,
|
lightUser: lila.user.LightUserApi,
|
||||||
getTournamentName: lila.tournament.GetTourName
|
getTournamentName: lila.tournament.GetTourName
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import lila.game.JsonView._
|
import lila.game.JsonView._
|
||||||
import LightUser.lightUserWrites
|
import LightUser.lightUserWrites
|
||||||
|
|
|
@ -12,7 +12,7 @@ final class BlogApi(
|
||||||
asyncCache: lila.memo.AsyncCache.Builder,
|
asyncCache: lila.memo.AsyncCache.Builder,
|
||||||
prismicUrl: String,
|
prismicUrl: String,
|
||||||
collection: String
|
collection: String
|
||||||
)(implicit ws: WSClient) {
|
)(implicit ec: scala.concurrent.ExecutionContext, ws: WSClient) {
|
||||||
|
|
||||||
def recent(
|
def recent(
|
||||||
api: Api,
|
api: Api,
|
||||||
|
|
|
@ -16,7 +16,7 @@ final class Env(
|
||||||
appConfig: Configuration,
|
appConfig: Configuration,
|
||||||
asyncCache: lila.memo.AsyncCache.Builder,
|
asyncCache: lila.memo.AsyncCache.Builder,
|
||||||
timelineApi: lila.timeline.EntryApi
|
timelineApi: lila.timeline.EntryApi
|
||||||
)(implicit system: akka.actor.ActorSystem, ws: play.api.libs.ws.WSClient) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: akka.actor.ActorSystem, ws: play.api.libs.ws.WSClient) {
|
||||||
|
|
||||||
private val config = appConfig.get[BlogConfig]("blog")(AutoConfig.loader)
|
private val config = appConfig.get[BlogConfig]("blog")(AutoConfig.loader)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ final class LastPostCache(
|
||||||
notifier: Notifier,
|
notifier: Notifier,
|
||||||
ttl: FiniteDuration,
|
ttl: FiniteDuration,
|
||||||
collection: String
|
collection: String
|
||||||
)(implicit system: akka.actor.ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: akka.actor.ActorSystem) {
|
||||||
|
|
||||||
private val cache = new Syncache[Boolean, List[MiniPost]](
|
private val cache = new Syncache[Boolean, List[MiniPost]](
|
||||||
name = "blog.lastPost",
|
name = "blog.lastPost",
|
||||||
|
|
|
@ -8,7 +8,7 @@ import lila.timeline.EntryApi
|
||||||
final private[blog] class Notifier(
|
final private[blog] class Notifier(
|
||||||
blogApi: BlogApi,
|
blogApi: BlogApi,
|
||||||
timelineApi: EntryApi
|
timelineApi: EntryApi
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def apply(id: String): Funit =
|
def apply(id: String): Funit =
|
||||||
blogApi.prismicApi flatMap { prismicApi =>
|
blogApi.prismicApi flatMap { prismicApi =>
|
||||||
|
|
|
@ -13,7 +13,7 @@ final class BookmarkApi(
|
||||||
coll: Coll,
|
coll: Coll,
|
||||||
gameRepo: GameRepo,
|
gameRepo: GameRepo,
|
||||||
paginator: PaginatorBuilder
|
paginator: PaginatorBuilder
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
private def exists(gameId: Game.ID, userId: User.ID): Fu[Boolean] =
|
private def exists(gameId: Game.ID, userId: User.ID): Fu[Boolean] =
|
||||||
coll exists selectId(gameId, userId)
|
coll exists selectId(gameId, userId)
|
||||||
|
@ -51,7 +51,7 @@ final class BookmarkApi(
|
||||||
def countByUser(user: User): Fu[Int] = coll.countSel(userIdQuery(user.id))
|
def countByUser(user: User): Fu[Int] = coll.countSel(userIdQuery(user.id))
|
||||||
|
|
||||||
def gamePaginatorByUser(user: User, page: Int) =
|
def gamePaginatorByUser(user: User, page: Int) =
|
||||||
paginator.byUser(user, page) dmap2 { _.game }
|
paginator.byUser(user, page) dmap { _.map(_.game) }
|
||||||
|
|
||||||
private def add(gameId: Game.ID, userId: User.ID, date: DateTime): Funit =
|
private def add(gameId: Game.ID, userId: User.ID, date: DateTime): Funit =
|
||||||
coll.insert
|
coll.insert
|
||||||
|
|
|
@ -20,7 +20,7 @@ final class Env(
|
||||||
appConfig: Configuration,
|
appConfig: Configuration,
|
||||||
db: lila.db.Db,
|
db: lila.db.Db,
|
||||||
gameRepo: lila.game.GameRepo
|
gameRepo: lila.game.GameRepo
|
||||||
)(implicit system: ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem) {
|
||||||
|
|
||||||
private val config = appConfig.get[BookmarkConfig]("bookmark")(AutoConfig.loader)
|
private val config = appConfig.get[BookmarkConfig]("bookmark")(AutoConfig.loader)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ final class PaginatorBuilder(
|
||||||
coll: Coll,
|
coll: Coll,
|
||||||
gameRepo: GameRepo,
|
gameRepo: GameRepo,
|
||||||
maxPerPage: lila.common.config.MaxPerPage
|
maxPerPage: lila.common.config.MaxPerPage
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def byUser(user: User, page: Int): Fu[Paginator[Bookmark]] =
|
def byUser(user: User, page: Int): Fu[Paginator[Bookmark]] =
|
||||||
paginator(new UserAdapter(user), page)
|
paginator(new UserAdapter(user), page)
|
||||||
|
@ -31,8 +31,7 @@ final class PaginatorBuilder(
|
||||||
.find(selector, $doc("g" -> true).some)
|
.find(selector, $doc("g" -> true).some)
|
||||||
.sort(sorting)
|
.sort(sorting)
|
||||||
.skip(offset)
|
.skip(offset)
|
||||||
.cursor[Bdoc]()
|
.list[Bdoc](length) dmap { _ flatMap { _ string "g" } }
|
||||||
.gather[List](length) map { _ flatMap { _.string("g") } }
|
|
||||||
games <- gameRepo gamesFromSecondary gameIds
|
games <- gameRepo gamesFromSecondary gameIds
|
||||||
} yield games map { g =>
|
} yield games map { g =>
|
||||||
Bookmark(g, user)
|
Bookmark(g, user)
|
||||||
|
|
|
@ -10,7 +10,7 @@ final class BotJsonView(
|
||||||
lightUserApi: lila.user.LightUserApi,
|
lightUserApi: lila.user.LightUserApi,
|
||||||
gameRepo: GameRepo,
|
gameRepo: GameRepo,
|
||||||
rematches: lila.game.Rematches
|
rematches: lila.game.Rematches
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def gameFull(game: Game): Fu[JsObject] = gameRepo.withInitialFen(game) flatMap gameFull
|
def gameFull(game: Game): Fu[JsObject] = gameRepo.withInitialFen(game) flatMap gameFull
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ final class BotPlayer(
|
||||||
chatApi: lila.chat.ChatApi,
|
chatApi: lila.chat.ChatApi,
|
||||||
gameRepo: GameRepo,
|
gameRepo: GameRepo,
|
||||||
isOfferingRematch: lila.round.IsOfferingRematch
|
isOfferingRematch: lila.round.IsOfferingRematch
|
||||||
)(implicit system: akka.actor.ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: akka.actor.ActorSystem) {
|
||||||
|
|
||||||
def apply(pov: Pov, me: User, uciStr: String, offeringDraw: Option[Boolean]): Funit =
|
def apply(pov: Pov, me: User, uciStr: String, offeringDraw: Option[Boolean]): Funit =
|
||||||
lila.common.Future.delay((pov.game.hasAi ?? 500) millis) {
|
lila.common.Future.delay((pov.game.hasAi ?? 500) millis) {
|
||||||
|
|
|
@ -9,7 +9,7 @@ final class Env(
|
||||||
lightUserApi: lila.user.LightUserApi,
|
lightUserApi: lila.user.LightUserApi,
|
||||||
rematches: lila.game.Rematches,
|
rematches: lila.game.Rematches,
|
||||||
isOfferingRematch: lila.round.IsOfferingRematch
|
isOfferingRematch: lila.round.IsOfferingRematch
|
||||||
)(implicit system: akka.actor.ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: akka.actor.ActorSystem) {
|
||||||
|
|
||||||
private def scheduler = system.scheduler
|
private def scheduler = system.scheduler
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ import scala.concurrent.duration._
|
||||||
|
|
||||||
final class GameStateStream(
|
final class GameStateStream(
|
||||||
jsonView: BotJsonView
|
jsonView: BotJsonView
|
||||||
)(implicit system: ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem) {
|
||||||
|
|
||||||
private case object SetOnline
|
private case object SetOnline
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ final class GameStateStream(
|
||||||
}
|
}
|
||||||
|
|
||||||
def pushState(g: Game) =
|
def pushState(g: Game) =
|
||||||
jsonView gameState Game.WithInitialFen(g, init.fen) map some flatMap queue.offer
|
jsonView gameState Game.WithInitialFen(g, init.fen) dmap some flatMap queue.offer
|
||||||
|
|
||||||
def pushChatLine(username: String, text: String, player: Boolean) =
|
def pushChatLine(username: String, text: String, player: Boolean) =
|
||||||
queue offer jsonView.chatLine(username, text, player).some
|
queue offer jsonView.chatLine(username, text, player).some
|
||||||
|
|
|
@ -8,7 +8,7 @@ import lila.memo.ExpireCallbackMemo
|
||||||
|
|
||||||
final class OnlineBots(
|
final class OnlineBots(
|
||||||
scheduler: akka.actor.Scheduler
|
scheduler: akka.actor.Scheduler
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
private val cache = new ExpireCallbackMemo(
|
private val cache = new ExpireCallbackMemo(
|
||||||
10.seconds,
|
10.seconds,
|
||||||
|
|
|
@ -18,12 +18,12 @@ final class ChallengeApi(
|
||||||
gameCache: lila.game.Cached,
|
gameCache: lila.game.Cached,
|
||||||
maxPlaying: Max,
|
maxPlaying: Max,
|
||||||
asyncCache: lila.memo.AsyncCache.Builder
|
asyncCache: lila.memo.AsyncCache.Builder
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import Challenge._
|
import Challenge._
|
||||||
|
|
||||||
def allFor(userId: User.ID): Fu[AllChallenges] =
|
def allFor(userId: User.ID): Fu[AllChallenges] =
|
||||||
createdByDestId(userId) zip createdByChallengerId(userId) map (AllChallenges.apply _).tupled
|
createdByDestId(userId) zip createdByChallengerId(userId) dmap (AllChallenges.apply _).tupled
|
||||||
|
|
||||||
// returns boolean success
|
// returns boolean success
|
||||||
def create(c: Challenge): Fu[Boolean] = isLimitedByMaxPlaying(c) flatMap {
|
def create(c: Challenge): Fu[Boolean] = isLimitedByMaxPlaying(c) flatMap {
|
||||||
|
@ -38,9 +38,9 @@ final class ChallengeApi(
|
||||||
|
|
||||||
def byId = repo byId _
|
def byId = repo byId _
|
||||||
|
|
||||||
def activeByIdFor(id: Challenge.ID, dest: User) = repo.byIdFor(id, dest).map(_.filter(_.active))
|
def activeByIdFor(id: Challenge.ID, dest: User) = repo.byIdFor(id, dest).dmap(_.filter(_.active))
|
||||||
|
|
||||||
def onlineByIdFor(id: Challenge.ID, dest: User) = repo.byIdFor(id, dest).map(_.filter(_.online))
|
def onlineByIdFor(id: Challenge.ID, dest: User) = repo.byIdFor(id, dest).dmap(_.filter(_.online))
|
||||||
|
|
||||||
val countInFor = asyncCache.clearable(
|
val countInFor = asyncCache.clearable(
|
||||||
name = "challenge.countInFor",
|
name = "challenge.countInFor",
|
||||||
|
@ -94,10 +94,10 @@ final class ChallengeApi(
|
||||||
else
|
else
|
||||||
c.userIds
|
c.userIds
|
||||||
.map { userId =>
|
.map { userId =>
|
||||||
gameCache.nbPlaying(userId) map (maxPlaying <=)
|
gameCache.nbPlaying(userId) dmap (maxPlaying <=)
|
||||||
}
|
}
|
||||||
.sequenceFu
|
.sequenceFu
|
||||||
.map(_ exists identity)
|
.dmap(_ exists identity)
|
||||||
|
|
||||||
private[challenge] def sweep: Funit =
|
private[challenge] def sweep: Funit =
|
||||||
repo.realTimeUnseenSince(DateTime.now minusSeconds 10, max = 50).flatMap { cs =>
|
repo.realTimeUnseenSince(DateTime.now minusSeconds 10, max = 50).flatMap { cs =>
|
||||||
|
|
|
@ -43,7 +43,7 @@ final class ChallengeGranter(
|
||||||
|
|
||||||
val ratingThreshold = 300
|
val ratingThreshold = 300
|
||||||
|
|
||||||
def apply(fromOption: Option[User], dest: User, perfType: Option[PerfType]): Fu[Option[ChallengeDenied]] =
|
def apply(fromOption: Option[User], dest: User, perfType: Option[PerfType])(implicit ec: scala.concurrent.ExecutionContext): Fu[Option[ChallengeDenied]] =
|
||||||
fromOption
|
fromOption
|
||||||
.fold[Fu[Option[ChallengeDenied.Reason]]](fuccess(YouAreAnon.some)) { from =>
|
.fold[Fu[Option[ChallengeDenied.Reason]]](fuccess(YouAreAnon.some)) { from =>
|
||||||
relationApi.fetchRelation(dest, from) zip
|
relationApi.fetchRelation(dest, from) zip
|
||||||
|
|
|
@ -7,7 +7,7 @@ import lila.user.User
|
||||||
final class ChallengeMaker(
|
final class ChallengeMaker(
|
||||||
userRepo: lila.user.UserRepo,
|
userRepo: lila.user.UserRepo,
|
||||||
gameRepo: lila.game.GameRepo
|
gameRepo: lila.game.GameRepo
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def makeRematchFor(gameId: Game.ID, dest: User): Fu[Option[Challenge]] =
|
def makeRematchFor(gameId: Game.ID, dest: User): Fu[Option[Challenge]] =
|
||||||
gameRepo game gameId flatMap {
|
gameRepo game gameId flatMap {
|
||||||
|
@ -15,7 +15,7 @@ final class ChallengeMaker(
|
||||||
game.opponentByUserId(dest.id).flatMap(_.userId) ?? userRepo.byId flatMap {
|
game.opponentByUserId(dest.id).flatMap(_.userId) ?? userRepo.byId flatMap {
|
||||||
_ ?? { challenger =>
|
_ ?? { challenger =>
|
||||||
Pov(game, challenger) ?? { pov =>
|
Pov(game, challenger) ?? { pov =>
|
||||||
makeRematch(pov, challenger, dest) map some
|
makeRematch(pov, challenger, dest) dmap some
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ final class ChallengeMaker(
|
||||||
Pov.ofUserId(game, challenger.id) ?? { pov =>
|
Pov.ofUserId(game, challenger.id) ?? { pov =>
|
||||||
pov.opponent.userId ?? userRepo.byId flatMap {
|
pov.opponent.userId ?? userRepo.byId flatMap {
|
||||||
_ ?? { dest =>
|
_ ?? { dest =>
|
||||||
makeRematch(pov, challenger, dest) map some
|
makeRematch(pov, challenger, dest) dmap some
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.joda.time.DateTime
|
||||||
import lila.common.config.Max
|
import lila.common.config.Max
|
||||||
import lila.db.dsl._
|
import lila.db.dsl._
|
||||||
|
|
||||||
final private class ChallengeRepo(coll: Coll, maxPerUser: Max) {
|
final private class ChallengeRepo(coll: Coll, maxPerUser: Max)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import BSONHandlers._
|
import BSONHandlers._
|
||||||
import Challenge._
|
import Challenge._
|
||||||
|
|
|
@ -8,7 +8,7 @@ import lila.socket.RemoteSocket.{ Protocol => P, _ }
|
||||||
final private class ChallengeSocket(
|
final private class ChallengeSocket(
|
||||||
api: ChallengeApi,
|
api: ChallengeApi,
|
||||||
remoteSocketApi: lila.socket.RemoteSocket
|
remoteSocketApi: lila.socket.RemoteSocket
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import ChallengeSocket._
|
import ChallengeSocket._
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ final class Env(
|
||||||
prefApi: lila.pref.PrefApi,
|
prefApi: lila.pref.PrefApi,
|
||||||
relationApi: lila.relation.RelationApi,
|
relationApi: lila.relation.RelationApi,
|
||||||
remoteSocketApi: lila.socket.RemoteSocket
|
remoteSocketApi: lila.socket.RemoteSocket
|
||||||
)(implicit system: akka.actor.ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: akka.actor.ActorSystem) {
|
||||||
|
|
||||||
private lazy val maxPlaying = appConfig.get[Max]("setup.max_playing")
|
private lazy val maxPlaying = appConfig.get[Max]("setup.max_playing")
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ final private[challenge] class Joiner(
|
||||||
gameRepo: lila.game.GameRepo,
|
gameRepo: lila.game.GameRepo,
|
||||||
userRepo: lila.user.UserRepo,
|
userRepo: lila.user.UserRepo,
|
||||||
onStart: lila.round.OnStart
|
onStart: lila.round.OnStart
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def apply(c: Challenge, destUser: Option[User]): Fu[Option[Pov]] =
|
def apply(c: Challenge, destUser: Option[User]): Fu[Option[Pov]] =
|
||||||
gameRepo exists c.id flatMap {
|
gameRepo exists c.id flatMap {
|
||||||
|
|
|
@ -14,7 +14,7 @@ final class CoachApi(
|
||||||
userRepo: UserRepo,
|
userRepo: UserRepo,
|
||||||
photographer: Photographer,
|
photographer: Photographer,
|
||||||
notifyApi: NotifyApi
|
notifyApi: NotifyApi
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import BsonHandlers._
|
import BsonHandlers._
|
||||||
|
|
||||||
|
@ -24,8 +24,8 @@ final class CoachApi(
|
||||||
userRepo named username flatMap { _ ?? find }
|
userRepo named username flatMap { _ ?? find }
|
||||||
|
|
||||||
def find(user: User): Fu[Option[Coach.WithUser]] = Granter(_.Coach)(user) ?? {
|
def find(user: User): Fu[Option[Coach.WithUser]] = Granter(_.Coach)(user) ?? {
|
||||||
byId(Coach.Id(user.id)) flatMap {
|
byId(Coach.Id(user.id)) dmap {
|
||||||
_ ?? withUser(user)
|
_ map withUser(user)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ final class CoachApi(
|
||||||
coachColl.update.one(
|
coachColl.update.one(
|
||||||
$id(User.normalize(username)),
|
$id(User.normalize(username)),
|
||||||
$set("approved" -> value)
|
$set("approved" -> value)
|
||||||
) map { result =>
|
) dmap { result =>
|
||||||
if (result.n > 0) "Done!"
|
if (result.n > 0) "Done!"
|
||||||
else "No such coach"
|
else "No such coach"
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ import lila.user.{ User, UserRepo }
|
||||||
final class CoachPager(
|
final class CoachPager(
|
||||||
userRepo: UserRepo,
|
userRepo: UserRepo,
|
||||||
coll: Coll
|
coll: Coll
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
val maxPerPage = lila.common.config.MaxPerPage(10)
|
val maxPerPage = lila.common.config.MaxPerPage(10)
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ final class Env(
|
||||||
notifyApi: lila.notify.NotifyApi,
|
notifyApi: lila.notify.NotifyApi,
|
||||||
db: lila.db.Db,
|
db: lila.db.Db,
|
||||||
imageRepo: lila.db.ImageRepo
|
imageRepo: lila.db.ImageRepo
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
private val config = appConfig.get[CoachConfig]("coach")(AutoConfig.loader)
|
private val config = appConfig.get[CoachConfig]("coach")(AutoConfig.loader)
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
package lila
|
package lila
|
||||||
|
|
||||||
import scalaz.{ ~>, Monoid }
|
import scalaz.Monoid
|
||||||
import scala.concurrent.ExecutionContext
|
import scala.concurrent.ExecutionContext
|
||||||
|
|
||||||
trait PackageObject extends Lilaisms {
|
trait PackageObject extends Lilaisms {
|
||||||
|
|
|
@ -34,5 +34,8 @@ trait QueryBuilderExt { self: dsl =>
|
||||||
|
|
||||||
def list[A: b.pack.Reader](limit: Int, readPreference: ReadPreference): Fu[List[A]] =
|
def list[A: b.pack.Reader](limit: Int, readPreference: ReadPreference): Fu[List[A]] =
|
||||||
gather[A, List](limit, readPreference)
|
gather[A, List](limit, readPreference)
|
||||||
|
|
||||||
|
def vector[A: b.pack.Reader](limit: Int, readPreference: ReadPreference): Fu[Vector[A]] =
|
||||||
|
gather[A, Vector](limit, readPreference)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,7 +10,7 @@ final class Env(
|
||||||
appConfig: Configuration,
|
appConfig: Configuration,
|
||||||
db: lila.db.Db,
|
db: lila.db.Db,
|
||||||
asyncCache: lila.memo.AsyncCache.Builder
|
asyncCache: lila.memo.AsyncCache.Builder
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
private lazy val eventColl = db(appConfig.get[CollName]("event.collection.event"))
|
private lazy val eventColl = db(appConfig.get[CollName]("event.collection.event"))
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import lila.db.dsl._
|
||||||
final class EventApi(
|
final class EventApi(
|
||||||
coll: Coll,
|
coll: Coll,
|
||||||
asyncCache: lila.memo.AsyncCache.Builder
|
asyncCache: lila.memo.AsyncCache.Builder
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import BsonHandlers._
|
import BsonHandlers._
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ final class Env(
|
||||||
makeClient: Index => ESClient,
|
makeClient: Index => ESClient,
|
||||||
postApi: lila.forum.PostApi,
|
postApi: lila.forum.PostApi,
|
||||||
postRepo: lila.forum.PostRepo
|
postRepo: lila.forum.PostRepo
|
||||||
)(implicit system: ActorSystem, mat: akka.stream.Materializer) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem, mat: akka.stream.Materializer) {
|
||||||
|
|
||||||
private val config = appConfig.get[ForumSearchConfig]("forumSearch")(AutoConfig.loader)
|
private val config = appConfig.get[ForumSearchConfig]("forumSearch")(AutoConfig.loader)
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ final class ForumSearchApi(
|
||||||
client: ESClient,
|
client: ESClient,
|
||||||
postApi: PostApi,
|
postApi: PostApi,
|
||||||
postRepo: PostRepo
|
postRepo: PostRepo
|
||||||
)(implicit mat: akka.stream.Materializer)
|
)(implicit ec: scala.concurrent.ExecutionContext, mat: akka.stream.Materializer)
|
||||||
extends SearchReadApi[PostView, Query] {
|
extends SearchReadApi[PostView, Query] {
|
||||||
|
|
||||||
def search(query: Query, from: From, size: Size) =
|
def search(query: Query, from: From, size: Size) =
|
||||||
|
@ -20,7 +20,7 @@ final class ForumSearchApi(
|
||||||
}
|
}
|
||||||
|
|
||||||
def count(query: Query) =
|
def count(query: Query) =
|
||||||
client.count(query) map (_.count)
|
client.count(query) dmap (_.count)
|
||||||
|
|
||||||
def store(post: Post) = postApi liteView post flatMap {
|
def store(post: Post) = postApi liteView post flatMap {
|
||||||
_ ?? { view =>
|
_ ?? { view =>
|
||||||
|
|
|
@ -5,7 +5,7 @@ import reactivemongo.api.bson._
|
||||||
import lila.db.dsl._
|
import lila.db.dsl._
|
||||||
import lila.user.User
|
import lila.user.User
|
||||||
|
|
||||||
final private class AggregationPipeline(store: Storage) {
|
final private class AggregationPipeline(store: Storage)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def aggregate[X](question: Question[X], user: User): Fu[List[Bdoc]] = store.coll {
|
def aggregate[X](question: Question[X], user: User): Fu[List[Bdoc]] = store.coll {
|
||||||
_.aggregateList(
|
_.aggregateList(
|
||||||
|
|
|
@ -15,7 +15,7 @@ final class Env(
|
||||||
prefApi: lila.pref.PrefApi,
|
prefApi: lila.pref.PrefApi,
|
||||||
relationApi: lila.relation.RelationApi,
|
relationApi: lila.relation.RelationApi,
|
||||||
mongo: lila.db.Env
|
mongo: lila.db.Env
|
||||||
)(implicit system: akka.actor.ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: akka.actor.ActorSystem) {
|
||||||
|
|
||||||
private lazy val db = mongo.asyncDb(
|
private lazy val db = mongo.asyncDb(
|
||||||
"insight",
|
"insight",
|
||||||
|
|
|
@ -16,7 +16,7 @@ final private class Indexer(
|
||||||
povToEntry: PovToEntry,
|
povToEntry: PovToEntry,
|
||||||
gameRepo: GameRepo,
|
gameRepo: GameRepo,
|
||||||
storage: Storage
|
storage: Storage
|
||||||
)(implicit mat: akka.stream.Materializer) {
|
)(implicit ec: scala.concurrent.ExecutionContext, mat: akka.stream.Materializer) {
|
||||||
|
|
||||||
private val workQueue = new WorkQueue(64)
|
private val workQueue = new WorkQueue(64)
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ final class InsightApi(
|
||||||
userCacheApi: UserCacheApi,
|
userCacheApi: UserCacheApi,
|
||||||
gameRepo: GameRepo,
|
gameRepo: GameRepo,
|
||||||
indexer: Indexer
|
indexer: Indexer
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import InsightApi._
|
import InsightApi._
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import scalaz.NonEmptyList
|
||||||
final private class PovToEntry(
|
final private class PovToEntry(
|
||||||
gameRepo: lila.game.GameRepo,
|
gameRepo: lila.game.GameRepo,
|
||||||
analysisRepo: lila.analyse.AnalysisRepo
|
analysisRepo: lila.analyse.AnalysisRepo
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
private type Ply = Int
|
private type Ply = Int
|
||||||
|
|
||||||
|
|
|
@ -7,9 +7,9 @@ import lila.user.User
|
||||||
final class Share(
|
final class Share(
|
||||||
prefApi: lila.pref.PrefApi,
|
prefApi: lila.pref.PrefApi,
|
||||||
relationApi: lila.relation.RelationApi
|
relationApi: lila.relation.RelationApi
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def getPrefId(insighted: User) = prefApi.getPrefById(insighted.id) map (_.insightShare)
|
def getPrefId(insighted: User) = prefApi.getPrefById(insighted.id) dmap (_.insightShare)
|
||||||
|
|
||||||
def grant(insighted: User, to: Option[User]): Fu[Boolean] =
|
def grant(insighted: User, to: Option[User]): Fu[Boolean] =
|
||||||
if (to ?? Granter(_.SeeInsight)) fuTrue
|
if (to ?? Granter(_.SeeInsight)) fuTrue
|
||||||
|
|
|
@ -7,7 +7,7 @@ import lila.db.AsyncColl
|
||||||
import lila.rating.BSONHandlers.perfTypeIdHandler
|
import lila.rating.BSONHandlers.perfTypeIdHandler
|
||||||
import lila.rating.PerfType
|
import lila.rating.PerfType
|
||||||
|
|
||||||
final private class Storage(val coll: AsyncColl) {
|
final private class Storage(val coll: AsyncColl)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import Storage._
|
import Storage._
|
||||||
import BSONHandlers._
|
import BSONHandlers._
|
||||||
|
|
|
@ -16,7 +16,7 @@ case class UserCache(
|
||||||
def id = _id
|
def id = _id
|
||||||
}
|
}
|
||||||
|
|
||||||
final private class UserCacheApi(coll: AsyncColl) {
|
final private class UserCacheApi(coll: AsyncColl)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
implicit private val userCacheBSONHandler = Macros.handler[UserCache]
|
implicit private val userCacheBSONHandler = Macros.handler[UserCache]
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ final class Env(
|
||||||
analysisRepo: lila.analyse.AnalysisRepo,
|
analysisRepo: lila.analyse.AnalysisRepo,
|
||||||
settingStore: lila.memo.SettingStore.Builder,
|
settingStore: lila.memo.SettingStore.Builder,
|
||||||
db: lila.db.Db
|
db: lila.db.Db
|
||||||
)(implicit system: ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem) {
|
||||||
|
|
||||||
private lazy val reportColl = db(CollName("irwin_report"))
|
private lazy val reportColl = db(CollName("irwin_report"))
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ final class IrwinApi(
|
||||||
reportApi: lila.report.ReportApi,
|
reportApi: lila.report.ReportApi,
|
||||||
notifyApi: lila.notify.NotifyApi,
|
notifyApi: lila.notify.NotifyApi,
|
||||||
mode: lila.memo.SettingStore[String]
|
mode: lila.memo.SettingStore[String]
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
val reportThreshold = 85
|
val reportThreshold = 85
|
||||||
val markThreshold = 93
|
val markThreshold = 93
|
||||||
|
@ -30,7 +30,7 @@ final class IrwinApi(
|
||||||
import BSONHandlers._
|
import BSONHandlers._
|
||||||
|
|
||||||
def dashboard: Fu[IrwinDashboard] =
|
def dashboard: Fu[IrwinDashboard] =
|
||||||
reportColl.ext.find($empty).sort($sort desc "date").list[IrwinReport](20) map IrwinDashboard.apply
|
reportColl.ext.find($empty).sort($sort desc "date").list[IrwinReport](20) dmap IrwinDashboard.apply
|
||||||
|
|
||||||
object reports {
|
object reports {
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ final class IrwinApi(
|
||||||
|
|
||||||
def withPovs(user: User): Fu[Option[IrwinReport.WithPovs]] = get(user) flatMap {
|
def withPovs(user: User): Fu[Option[IrwinReport.WithPovs]] = get(user) flatMap {
|
||||||
_ ?? { report =>
|
_ ?? { report =>
|
||||||
gameRepo.gamesFromSecondary(report.games.map(_.gameId)) map { games =>
|
gameRepo.gamesFromSecondary(report.games.map(_.gameId)) dmap { games =>
|
||||||
val povs = games.flatMap { g =>
|
val povs = games.flatMap { g =>
|
||||||
Pov(g, user) map { g.id -> _ }
|
Pov(g, user) map { g.id -> _ }
|
||||||
}.toMap
|
}.toMap
|
||||||
|
@ -56,7 +56,7 @@ final class IrwinApi(
|
||||||
}
|
}
|
||||||
|
|
||||||
private def getSuspect(suspectId: User.ID) =
|
private def getSuspect(suspectId: User.ID) =
|
||||||
userRepo byId suspectId orFail s"suspect $suspectId not found" map Suspect.apply
|
userRepo byId suspectId orFail s"suspect $suspectId not found" dmap Suspect.apply
|
||||||
|
|
||||||
private def markOrReport(report: IrwinReport): Funit =
|
private def markOrReport(report: IrwinReport): Funit =
|
||||||
if (report.activation >= markThreshold && mode.get() == "mark")
|
if (report.activation >= markThreshold && mode.get() == "mark")
|
||||||
|
@ -64,7 +64,7 @@ final class IrwinApi(
|
||||||
lila.mon.mod.irwin.mark.increment()
|
lila.mon.mod.irwin.mark.increment()
|
||||||
else if (report.activation >= reportThreshold && mode.get() != "none") for {
|
else if (report.activation >= reportThreshold && mode.get() != "none") for {
|
||||||
suspect <- getSuspect(report.suspectId.value)
|
suspect <- getSuspect(report.suspectId.value)
|
||||||
irwin <- userRepo byId "irwin" orFail s"Irwin user not found" map Mod.apply
|
irwin <- userRepo byId "irwin" orFail s"Irwin user not found" dmap Mod.apply
|
||||||
_ <- reportApi.create(
|
_ <- reportApi.create(
|
||||||
Report.Candidate(
|
Report.Candidate(
|
||||||
reporter = Reporter(irwin.user),
|
reporter = Reporter(irwin.user),
|
||||||
|
|
|
@ -24,7 +24,7 @@ final class IrwinStream {
|
||||||
queue offer req
|
queue offer req
|
||||||
}
|
}
|
||||||
|
|
||||||
queue.watchCompletion foreach { _ =>
|
queue.watchCompletion dforeach { _ =>
|
||||||
Bus.unsubscribe(sub, classifier)
|
Bus.unsubscribe(sub, classifier)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@ import lila.common.config._
|
||||||
final class Env(
|
final class Env(
|
||||||
appConfig: Configuration,
|
appConfig: Configuration,
|
||||||
db: lila.db.Db
|
db: lila.db.Db
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
lazy val api = new LearnApi(
|
lazy val api = new LearnApi(
|
||||||
coll = db(appConfig.get[CollName]("learn.collection.progress"))
|
coll = db(appConfig.get[CollName]("learn.collection.progress"))
|
||||||
)
|
)
|
||||||
|
|
|
@ -3,12 +3,12 @@ package lila.learn
|
||||||
import lila.db.dsl._
|
import lila.db.dsl._
|
||||||
import lila.user.User
|
import lila.user.User
|
||||||
|
|
||||||
final class LearnApi(coll: Coll) {
|
final class LearnApi(coll: Coll)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import BSONHandlers._
|
import BSONHandlers._
|
||||||
|
|
||||||
def get(user: User): Fu[LearnProgress] =
|
def get(user: User): Fu[LearnProgress] =
|
||||||
coll.one[LearnProgress]($id(user.id)) map { _ | LearnProgress.empty(LearnProgress.Id(user.id)) }
|
coll.one[LearnProgress]($id(user.id)) dmap { _ | LearnProgress.empty(LearnProgress.Id(user.id)) }
|
||||||
|
|
||||||
private def save(p: LearnProgress): Funit =
|
private def save(p: LearnProgress): Funit =
|
||||||
coll.update.one($id(p.id), p, upsert = true).void
|
coll.update.one($id(p.id), p, upsert = true).void
|
||||||
|
|
|
@ -6,7 +6,7 @@ final private class AbortListener(
|
||||||
userRepo: lila.user.UserRepo,
|
userRepo: lila.user.UserRepo,
|
||||||
seekApi: SeekApi,
|
seekApi: SeekApi,
|
||||||
lobbyTrouper: LobbyTrouper
|
lobbyTrouper: LobbyTrouper
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def apply(pov: Pov): Funit =
|
def apply(pov: Pov): Funit =
|
||||||
(pov.game.isCorrespondence ?? recreateSeek(pov)) >>-
|
(pov.game.isCorrespondence ?? recreateSeek(pov)) >>-
|
||||||
|
|
|
@ -10,7 +10,7 @@ import lila.user.User
|
||||||
final private class Biter(
|
final private class Biter(
|
||||||
userRepo: lila.user.UserRepo,
|
userRepo: lila.user.UserRepo,
|
||||||
gameRepo: lila.game.GameRepo
|
gameRepo: lila.game.GameRepo
|
||||||
)(implicit idGenerator: lila.game.IdGenerator) {
|
)(implicit ec: scala.concurrent.ExecutionContext, idGenerator: lila.game.IdGenerator) {
|
||||||
|
|
||||||
def apply(hook: Hook, sri: Sri, user: Option[LobbyUser]): Fu[JoinHook] =
|
def apply(hook: Hook, sri: Sri, user: Option[LobbyUser]): Fu[JoinHook] =
|
||||||
if (canJoin(hook, user)) join(hook, sri, user)
|
if (canJoin(hook, user)) join(hook, sri, user)
|
||||||
|
|
|
@ -21,6 +21,7 @@ final class Env(
|
||||||
remoteSocketApi: lila.socket.RemoteSocket
|
remoteSocketApi: lila.socket.RemoteSocket
|
||||||
)(
|
)(
|
||||||
implicit
|
implicit
|
||||||
|
ec: scala.concurrent.ExecutionContext,
|
||||||
system: akka.actor.ActorSystem,
|
system: akka.actor.ActorSystem,
|
||||||
idGenerator: lila.game.IdGenerator
|
idGenerator: lila.game.IdGenerator
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -25,7 +25,7 @@ final class LobbySocket(
|
||||||
relationApi: lila.relation.RelationApi,
|
relationApi: lila.relation.RelationApi,
|
||||||
poolApi: PoolApi,
|
poolApi: PoolApi,
|
||||||
system: akka.actor.ActorSystem
|
system: akka.actor.ActorSystem
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import LobbySocket._
|
import LobbySocket._
|
||||||
import Protocol._
|
import Protocol._
|
||||||
|
|
|
@ -21,7 +21,7 @@ final private class LobbyTrouper(
|
||||||
playbanApi: lila.playban.PlaybanApi,
|
playbanApi: lila.playban.PlaybanApi,
|
||||||
poolApi: lila.pool.PoolApi,
|
poolApi: lila.pool.PoolApi,
|
||||||
onStart: lila.round.OnStart
|
onStart: lila.round.OnStart
|
||||||
) extends Trouper {
|
)(implicit ec: scala.concurrent.ExecutionContext) extends Trouper {
|
||||||
|
|
||||||
import LobbyTrouper._
|
import LobbyTrouper._
|
||||||
|
|
||||||
|
@ -206,7 +206,9 @@ private object LobbyTrouper {
|
||||||
def start(
|
def start(
|
||||||
broomPeriod: FiniteDuration,
|
broomPeriod: FiniteDuration,
|
||||||
resyncIdsPeriod: FiniteDuration
|
resyncIdsPeriod: FiniteDuration
|
||||||
)(makeTrouper: () => LobbyTrouper)(implicit system: akka.actor.ActorSystem) = {
|
)(
|
||||||
|
makeTrouper: () => LobbyTrouper
|
||||||
|
)(implicit ec: scala.concurrent.ExecutionContext, system: akka.actor.ActorSystem) = {
|
||||||
val trouper = makeTrouper()
|
val trouper = makeTrouper()
|
||||||
lila.common.Bus.subscribe(trouper, "lobbyTrouper")
|
lila.common.Bus.subscribe(trouper, "lobbyTrouper")
|
||||||
system.scheduler.scheduleWithFixedDelay(15 seconds, resyncIdsPeriod)(() => trouper ! actorApi.Resync)
|
system.scheduler.scheduleWithFixedDelay(15 seconds, resyncIdsPeriod)(() => trouper ! actorApi.Resync)
|
||||||
|
|
|
@ -12,7 +12,7 @@ final class SeekApi(
|
||||||
biter: Biter,
|
biter: Biter,
|
||||||
relationApi: lila.relation.RelationApi,
|
relationApi: lila.relation.RelationApi,
|
||||||
asyncCache: lila.memo.AsyncCache.Builder
|
asyncCache: lila.memo.AsyncCache.Builder
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
import config._
|
import config._
|
||||||
|
|
||||||
sealed private trait CacheKey
|
sealed private trait CacheKey
|
||||||
|
|
|
@ -10,7 +10,7 @@ final private class GameStarter(
|
||||||
gameRepo: GameRepo,
|
gameRepo: GameRepo,
|
||||||
idGenerator: IdGenerator,
|
idGenerator: IdGenerator,
|
||||||
onStart: Game.Id => Unit
|
onStart: Game.Id => Unit
|
||||||
)(implicit mat: akka.stream.Materializer) {
|
)(implicit ec: scala.concurrent.ExecutionContext, mat: akka.stream.Materializer) {
|
||||||
|
|
||||||
import PoolApi._
|
import PoolApi._
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,10 @@ import scala.concurrent.Promise
|
||||||
|
|
||||||
import lila.common.Bus
|
import lila.common.Bus
|
||||||
|
|
||||||
final private class HookThieve()(implicit system: akka.actor.ActorSystem) {
|
final private class HookThieve()(
|
||||||
|
implicit ec: scala.concurrent.ExecutionContext,
|
||||||
|
system: akka.actor.ActorSystem
|
||||||
|
) {
|
||||||
|
|
||||||
import HookThieve._
|
import HookThieve._
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,8 @@ final private class PoolActor(
|
||||||
|
|
||||||
var nextWave: Cancellable = _
|
var nextWave: Cancellable = _
|
||||||
|
|
||||||
|
implicit def ec = context.dispatcher
|
||||||
|
|
||||||
def scheduleWave() =
|
def scheduleWave() =
|
||||||
nextWave = context.system.scheduler.scheduleOnce(
|
nextWave = context.system.scheduler.scheduleOnce(
|
||||||
config.wave.every + Random.nextInt(1000).millis,
|
config.wave.every + Random.nextInt(1000).millis,
|
||||||
|
|
|
@ -26,11 +26,11 @@ final class PoolApi(
|
||||||
}.toMap
|
}.toMap
|
||||||
|
|
||||||
def join(poolId: PoolConfig.Id, joiner: Joiner) =
|
def join(poolId: PoolConfig.Id, joiner: Joiner) =
|
||||||
playbanApi.hasCurrentBan(joiner.userId) foreach {
|
playbanApi.hasCurrentBan(joiner.userId) dforeach {
|
||||||
case false =>
|
case false =>
|
||||||
actors foreach {
|
actors foreach {
|
||||||
case (id, actor) if id == poolId =>
|
case (id, actor) if id == poolId =>
|
||||||
playbanApi.getRageSit(joiner.userId).foreach(actor ! Join(joiner, _))
|
playbanApi.getRageSit(joiner.userId).dforeach(actor ! Join(joiner, _))
|
||||||
case (_, actor) => actor ! Leave(joiner.userId)
|
case (_, actor) => actor ! Leave(joiner.userId)
|
||||||
}
|
}
|
||||||
case _ =>
|
case _ =>
|
||||||
|
|
|
@ -10,7 +10,7 @@ final class Env(
|
||||||
studyApi: lila.study.StudyApi,
|
studyApi: lila.study.StudyApi,
|
||||||
asyncCache: lila.memo.AsyncCache.Builder,
|
asyncCache: lila.memo.AsyncCache.Builder,
|
||||||
db: lila.db.Db
|
db: lila.db.Db
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
private lazy val coll = db(CollName("practice_progress"))
|
private lazy val coll = db(CollName("practice_progress"))
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ final class PracticeApi(
|
||||||
configStore: lila.memo.ConfigStore[PracticeConfig],
|
configStore: lila.memo.ConfigStore[PracticeConfig],
|
||||||
asyncCache: lila.memo.AsyncCache.Builder,
|
asyncCache: lila.memo.AsyncCache.Builder,
|
||||||
studyApi: lila.study.StudyApi
|
studyApi: lila.study.StudyApi
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import BSONHandlers._
|
import BSONHandlers._
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ final class PracticeApi(
|
||||||
} yield UserStudy(up, practiceStudy, publishedChapters, sc, section)
|
} yield UserStudy(up, practiceStudy, publishedChapters, sc, section)
|
||||||
|
|
||||||
object config {
|
object config {
|
||||||
def get = configStore.get map (_ | PracticeConfig.empty)
|
def get = configStore.get dmap (_ | PracticeConfig.empty)
|
||||||
def set = configStore.set _
|
def set = configStore.set _
|
||||||
def form = configStore.makeForm
|
def form = configStore.makeForm
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ final class PracticeApi(
|
||||||
import PracticeProgress.NbMoves
|
import PracticeProgress.NbMoves
|
||||||
|
|
||||||
def get(user: User): Fu[PracticeProgress] =
|
def get(user: User): Fu[PracticeProgress] =
|
||||||
coll.one[PracticeProgress]($id(user.id)) map {
|
coll.one[PracticeProgress]($id(user.id)) dmap {
|
||||||
_ | PracticeProgress.empty(PracticeProgress.Id(user.id))
|
_ | PracticeProgress.empty(PracticeProgress.Id(user.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import reactivemongo.api.bson._
|
||||||
import lila.db.dsl._
|
import lila.db.dsl._
|
||||||
import lila.user.User
|
import lila.user.User
|
||||||
|
|
||||||
final private class DeviceApi(coll: Coll) {
|
final private class DeviceApi(coll: Coll)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
implicit private val DeviceBSONHandler = Macros.handler[Device]
|
implicit private val DeviceBSONHandler = Macros.handler[Device]
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ final private class DeviceApi(coll: Coll) {
|
||||||
.list[Device](max)
|
.list[Device](max)
|
||||||
|
|
||||||
private[push] def findLastOneByUserId(platform: String)(userId: String): Fu[Option[Device]] =
|
private[push] def findLastOneByUserId(platform: String)(userId: String): Fu[Option[Device]] =
|
||||||
findLastManyByUserId(platform, 1)(userId) map (_.headOption)
|
findLastManyByUserId(platform, 1)(userId) dmap (_.headOption)
|
||||||
|
|
||||||
def register(user: User, platform: String, deviceId: String) = {
|
def register(user: User, platform: String, deviceId: String) = {
|
||||||
lila.mon.push.register.in(platform).increment()
|
lila.mon.push.register.in(platform).increment()
|
||||||
|
|
|
@ -28,7 +28,7 @@ final class Env(
|
||||||
userRepo: lila.user.UserRepo,
|
userRepo: lila.user.UserRepo,
|
||||||
getLightUser: lila.common.LightUser.Getter,
|
getLightUser: lila.common.LightUser.Getter,
|
||||||
proxyRepo: lila.round.GameProxyRepo
|
proxyRepo: lila.round.GameProxyRepo
|
||||||
)(implicit system: ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem) {
|
||||||
|
|
||||||
private val config = appConfig.get[PushConfig]("push")(AutoConfig.loader)
|
private val config = appConfig.get[PushConfig]("push")(AutoConfig.loader)
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,7 @@ final private class FirebasePush(
|
||||||
deviceApi: DeviceApi,
|
deviceApi: DeviceApi,
|
||||||
ws: WSClient,
|
ws: WSClient,
|
||||||
config: OneSignalPush.Config
|
config: OneSignalPush.Config
|
||||||
)(implicit system: akka.actor.ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: akka.actor.ActorSystem) {
|
||||||
|
|
||||||
private val workQueue = new WorkQueue(512)
|
private val workQueue = new WorkQueue(512)
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ final private class OneSignalPush(
|
||||||
deviceApi: DeviceApi,
|
deviceApi: DeviceApi,
|
||||||
ws: WSClient,
|
ws: WSClient,
|
||||||
config: OneSignalPush.Config
|
config: OneSignalPush.Config
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import config._
|
import config._
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ final private class PushApi(
|
||||||
userRepo: lila.user.UserRepo,
|
userRepo: lila.user.UserRepo,
|
||||||
implicit val lightUser: LightUser.Getter,
|
implicit val lightUser: LightUser.Getter,
|
||||||
proxyRepo: lila.round.GameProxyRepo
|
proxyRepo: lila.round.GameProxyRepo
|
||||||
)(implicit system: ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem) {
|
||||||
|
|
||||||
def finish(game: Game): Funit =
|
def finish(game: Game): Funit =
|
||||||
if (!game.isCorrespondence || game.hasAi) funit
|
if (!game.isCorrespondence || game.hasAi) funit
|
||||||
|
@ -271,7 +271,7 @@ final private class PushApi(
|
||||||
private def IfAway(pov: Pov)(f: => Funit): Funit =
|
private def IfAway(pov: Pov)(f: => Funit): Funit =
|
||||||
lila.common.Bus.ask[Boolean]("roundSocket") { p =>
|
lila.common.Bus.ask[Boolean]("roundSocket") { p =>
|
||||||
Tell(pov.gameId, IsOnGame(pov.color, p))
|
Tell(pov.gameId, IsOnGame(pov.color, p))
|
||||||
}(system) flatMap {
|
} flatMap {
|
||||||
case true => funit
|
case true => funit
|
||||||
case false => f
|
case false => f
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,7 @@ final private class WebPush(
|
||||||
webSubscriptionApi: WebSubscriptionApi,
|
webSubscriptionApi: WebSubscriptionApi,
|
||||||
config: WebPush.Config,
|
config: WebPush.Config,
|
||||||
ws: WSClient
|
ws: WSClient
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def apply(userId: User.ID)(data: => PushApi.Data): Funit =
|
def apply(userId: User.ID)(data: => PushApi.Data): Funit =
|
||||||
webSubscriptionApi.getSubscriptions(5)(userId) flatMap { subscriptions =>
|
webSubscriptionApi.getSubscriptions(5)(userId) flatMap { subscriptions =>
|
||||||
|
|
|
@ -7,7 +7,7 @@ import reactivemongo.api.bson._
|
||||||
import lila.db.dsl._
|
import lila.db.dsl._
|
||||||
import lila.user.User
|
import lila.user.User
|
||||||
|
|
||||||
final class WebSubscriptionApi(coll: Coll) {
|
final class WebSubscriptionApi(coll: Coll)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def getSubscriptions(max: Int)(userId: User.ID): Fu[List[WebSubscription]] =
|
def getSubscriptions(max: Int)(userId: User.ID): Fu[List[WebSubscription]] =
|
||||||
coll.ext
|
coll.ext
|
||||||
|
|
|
@ -5,7 +5,7 @@ import reactivemongo.api.bson._
|
||||||
|
|
||||||
import lila.db.dsl._
|
import lila.db.dsl._
|
||||||
|
|
||||||
final private class AnonConfigRepo(coll: Coll) {
|
final private class AnonConfigRepo(coll: Coll)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def update(req: RequestHeader)(f: UserConfig => UserConfig): Funit =
|
def update(req: RequestHeader)(f: UserConfig => UserConfig): Funit =
|
||||||
configOption(req) flatMap {
|
configOption(req) flatMap {
|
||||||
|
@ -29,7 +29,7 @@ final private class AnonConfigRepo(coll: Coll) {
|
||||||
logger.warn("Can't load config", e)
|
logger.warn("Can't load config", e)
|
||||||
none[UserConfig]
|
none[UserConfig]
|
||||||
}
|
}
|
||||||
} map (_ | UserConfig.default(sid))
|
} dmap (_ | UserConfig.default(sid))
|
||||||
|
|
||||||
private def configOption(req: RequestHeader): Fu[Option[UserConfig]] =
|
private def configOption(req: RequestHeader): Fu[Option[UserConfig]] =
|
||||||
sessionId(req).??(s => config(s) map (_.some))
|
sessionId(req).??(s => config(s) map (_.some))
|
||||||
|
@ -37,7 +37,7 @@ final private class AnonConfigRepo(coll: Coll) {
|
||||||
def filter(req: RequestHeader): Fu[FilterConfig] =
|
def filter(req: RequestHeader): Fu[FilterConfig] =
|
||||||
sessionId(req) ?? { sid =>
|
sessionId(req) ?? { sid =>
|
||||||
coll.primitiveOne[FilterConfig]($id(sid), "filter")
|
coll.primitiveOne[FilterConfig]($id(sid), "filter")
|
||||||
} map (_ | FilterConfig.default)
|
} dmap (_ | FilterConfig.default)
|
||||||
|
|
||||||
private def sessionId(req: RequestHeader): Option[String] =
|
private def sessionId(req: RequestHeader): Option[String] =
|
||||||
lila.common.HTTPRequest sid req
|
lila.common.HTTPRequest sid req
|
||||||
|
|
|
@ -14,7 +14,7 @@ final class Env(
|
||||||
fishnetPlayer: lila.fishnet.Player,
|
fishnetPlayer: lila.fishnet.Player,
|
||||||
onStart: lila.round.OnStart,
|
onStart: lila.round.OnStart,
|
||||||
gameCache: lila.game.Cached
|
gameCache: lila.game.Cached
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
private lazy val maxPlaying = appConfig.get[Max]("setup.max_playing")
|
private lazy val maxPlaying = appConfig.get[Max]("setup.max_playing")
|
||||||
private lazy val anonConfigRepo = new AnonConfigRepo(db(CollName("config")))
|
private lazy val anonConfigRepo = new AnonConfigRepo(db(CollName("config")))
|
||||||
|
|
|
@ -14,7 +14,7 @@ final class FormFactory(
|
||||||
import Mappings._
|
import Mappings._
|
||||||
|
|
||||||
def filterFilled(implicit ctx: UserContext): Fu[(Form[FilterConfig], FilterConfig)] =
|
def filterFilled(implicit ctx: UserContext): Fu[(Form[FilterConfig], FilterConfig)] =
|
||||||
filterConfig map { f =>
|
filterConfig dmap { f =>
|
||||||
filter.fill(f) -> f
|
filter.fill(f) -> f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,10 +27,10 @@ final class FormFactory(
|
||||||
)(FilterConfig.<<)(_.>>)
|
)(FilterConfig.<<)(_.>>)
|
||||||
)
|
)
|
||||||
|
|
||||||
def filterConfig(implicit ctx: UserContext): Fu[FilterConfig] = savedConfig map (_.filter)
|
def filterConfig(implicit ctx: UserContext): Fu[FilterConfig] = savedConfig dmap (_.filter)
|
||||||
|
|
||||||
def aiFilled(fen: Option[FEN])(implicit ctx: UserContext): Fu[Form[AiConfig]] =
|
def aiFilled(fen: Option[FEN])(implicit ctx: UserContext): Fu[Form[AiConfig]] =
|
||||||
aiConfig map { config =>
|
aiConfig dmap { config =>
|
||||||
ai fill fen.fold(config) { f =>
|
ai fill fen.fold(config) { f =>
|
||||||
config.copy(fen = f.some, variant = chess.variant.FromPosition)
|
config.copy(fen = f.some, variant = chess.variant.FromPosition)
|
||||||
}
|
}
|
||||||
|
@ -51,10 +51,10 @@ final class FormFactory(
|
||||||
.verifying("Can't play that time control from a position", _.timeControlFromPosition)
|
.verifying("Can't play that time control from a position", _.timeControlFromPosition)
|
||||||
)
|
)
|
||||||
|
|
||||||
def aiConfig(implicit ctx: UserContext): Fu[AiConfig] = savedConfig map (_.ai)
|
def aiConfig(implicit ctx: UserContext): Fu[AiConfig] = savedConfig dmap (_.ai)
|
||||||
|
|
||||||
def friendFilled(fen: Option[FEN])(implicit ctx: UserContext): Fu[Form[FriendConfig]] =
|
def friendFilled(fen: Option[FEN])(implicit ctx: UserContext): Fu[Form[FriendConfig]] =
|
||||||
friendConfig map { config =>
|
friendConfig dmap { config =>
|
||||||
friend(ctx) fill fen.fold(config) { f =>
|
friend(ctx) fill fen.fold(config) { f =>
|
||||||
config.copy(fen = f.some, variant = chess.variant.FromPosition)
|
config.copy(fen = f.some, variant = chess.variant.FromPosition)
|
||||||
}
|
}
|
||||||
|
@ -75,10 +75,10 @@ final class FormFactory(
|
||||||
.verifying("invalidFen", _.validFen)
|
.verifying("invalidFen", _.validFen)
|
||||||
)
|
)
|
||||||
|
|
||||||
def friendConfig(implicit ctx: UserContext): Fu[FriendConfig] = savedConfig map (_.friend)
|
def friendConfig(implicit ctx: UserContext): Fu[FriendConfig] = savedConfig dmap (_.friend)
|
||||||
|
|
||||||
def hookFilled(timeModeString: Option[String])(implicit ctx: UserContext): Fu[Form[HookConfig]] =
|
def hookFilled(timeModeString: Option[String])(implicit ctx: UserContext): Fu[Form[HookConfig]] =
|
||||||
hookConfig map (_ withTimeModeString timeModeString) map hook(ctx).fill
|
hookConfig dmap (_ withTimeModeString timeModeString) dmap hook(ctx).fill
|
||||||
|
|
||||||
def hook(ctx: UserContext) = Form(
|
def hook(ctx: UserContext) = Form(
|
||||||
mapping(
|
mapping(
|
||||||
|
@ -95,7 +95,7 @@ final class FormFactory(
|
||||||
.verifying("Can't create rated unlimited in lobby", _.noRatedUnlimited)
|
.verifying("Can't create rated unlimited in lobby", _.noRatedUnlimited)
|
||||||
)
|
)
|
||||||
|
|
||||||
def hookConfig(implicit ctx: UserContext): Fu[HookConfig] = savedConfig map (_.hook)
|
def hookConfig(implicit ctx: UserContext): Fu[HookConfig] = savedConfig dmap (_.hook)
|
||||||
|
|
||||||
lazy val api = Form(
|
lazy val api = Form(
|
||||||
mapping(
|
mapping(
|
||||||
|
|
|
@ -14,7 +14,7 @@ final private[setup] class Processor(
|
||||||
anonConfigRepo: AnonConfigRepo,
|
anonConfigRepo: AnonConfigRepo,
|
||||||
userConfigRepo: UserConfigRepo,
|
userConfigRepo: UserConfigRepo,
|
||||||
onStart: lila.round.OnStart
|
onStart: lila.round.OnStart
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def filter(config: FilterConfig)(implicit ctx: UserContext): Funit =
|
def filter(config: FilterConfig)(implicit ctx: UserContext): Funit =
|
||||||
saveConfig(_ withFilter config)
|
saveConfig(_ withFilter config)
|
||||||
|
@ -44,7 +44,7 @@ final private[setup] class Processor(
|
||||||
Created(hook.id)
|
Created(hook.id)
|
||||||
}
|
}
|
||||||
case Right(Some(seek)) =>
|
case Right(Some(seek)) =>
|
||||||
ctx.userId.??(gameCache.nbPlaying) map { nbPlaying =>
|
ctx.userId.??(gameCache.nbPlaying) dmap { nbPlaying =>
|
||||||
if (maxPlaying <= nbPlaying) Refused
|
if (maxPlaying <= nbPlaying) Refused
|
||||||
else {
|
else {
|
||||||
Bus.publish(AddSeek(seek), "lobbyTrouper")
|
Bus.publish(AddSeek(seek), "lobbyTrouper")
|
||||||
|
|
|
@ -5,7 +5,7 @@ import reactivemongo.api.bson._
|
||||||
import lila.db.dsl._
|
import lila.db.dsl._
|
||||||
import lila.user.User
|
import lila.user.User
|
||||||
|
|
||||||
final private class UserConfigRepo(coll: Coll) {
|
final private class UserConfigRepo(coll: Coll)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
def update(user: User)(f: UserConfig => UserConfig): Funit =
|
def update(user: User)(f: UserConfig => UserConfig): Funit =
|
||||||
config(user) flatMap { config =>
|
config(user) flatMap { config =>
|
||||||
|
@ -24,8 +24,8 @@ final private class UserConfigRepo(coll: Coll) {
|
||||||
logger.warn("Can't load config", e)
|
logger.warn("Can't load config", e)
|
||||||
none[UserConfig]
|
none[UserConfig]
|
||||||
}
|
}
|
||||||
} map (_ | UserConfig.default(user.id))
|
} dmap (_ | UserConfig.default(user.id))
|
||||||
|
|
||||||
def filter(user: User): Fu[FilterConfig] =
|
def filter(user: User): Fu[FilterConfig] =
|
||||||
coll.primitiveOne[FilterConfig]($id(user.id), "filter") map (_ | FilterConfig.default)
|
coll.primitiveOne[FilterConfig]($id(user.id), "filter") dmap (_ | FilterConfig.default)
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ final class Env(
|
||||||
timeline: lila.hub.actors.Timeline,
|
timeline: lila.hub.actors.Timeline,
|
||||||
db: lila.db.Db,
|
db: lila.db.Db,
|
||||||
imageRepo: lila.db.ImageRepo
|
imageRepo: lila.db.ImageRepo
|
||||||
)(implicit system: ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem) {
|
||||||
|
|
||||||
implicit private val keywordLoader = strLoader(Stream.Keyword.apply)
|
implicit private val keywordLoader = strLoader(Stream.Keyword.apply)
|
||||||
private val config = appConfig.get[StreamerConfig]("streamer")(AutoConfig.loader)
|
private val config = appConfig.get[StreamerConfig]("streamer")(AutoConfig.loader)
|
||||||
|
|
|
@ -47,7 +47,7 @@ object LiveStreams {
|
||||||
final class LiveStreamApi(
|
final class LiveStreamApi(
|
||||||
asyncCache: lila.memo.AsyncCache.Builder,
|
asyncCache: lila.memo.AsyncCache.Builder,
|
||||||
streamingActor: ActorRef
|
streamingActor: ActorRef
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
private val cache = asyncCache.single[LiveStreams](
|
private val cache = asyncCache.single[LiveStreams](
|
||||||
name = "streamer.liveStreams",
|
name = "streamer.liveStreams",
|
||||||
|
|
|
@ -14,7 +14,7 @@ final class StreamerApi(
|
||||||
asyncCache: lila.memo.AsyncCache.Builder,
|
asyncCache: lila.memo.AsyncCache.Builder,
|
||||||
photographer: Photographer,
|
photographer: Photographer,
|
||||||
notifyApi: lila.notify.NotifyApi
|
notifyApi: lila.notify.NotifyApi
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import BsonHandlers._
|
import BsonHandlers._
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ final class StreamerApi(
|
||||||
userRepo named username flatMap { _ ?? find }
|
userRepo named username flatMap { _ ?? find }
|
||||||
|
|
||||||
def find(user: User): Fu[Option[Streamer.WithUser]] =
|
def find(user: User): Fu[Option[Streamer.WithUser]] =
|
||||||
byId(Streamer.Id(user.id)) flatMap {
|
byId(Streamer.Id(user.id)) dmap {
|
||||||
_ ?? withUser(user)
|
_ map { Streamer.WithUser(_, user) }
|
||||||
}
|
}
|
||||||
|
|
||||||
def findOrInit(user: User): Fu[Option[Streamer.WithUser]] =
|
def findOrInit(user: User): Fu[Option[Streamer.WithUser]] =
|
||||||
|
@ -38,14 +38,14 @@ final class StreamerApi(
|
||||||
}
|
}
|
||||||
|
|
||||||
def withUser(s: Stream): Fu[Option[Streamer.WithUserAndStream]] =
|
def withUser(s: Stream): Fu[Option[Streamer.WithUserAndStream]] =
|
||||||
userRepo named s.streamer.userId map {
|
userRepo named s.streamer.userId dmap {
|
||||||
_ map { user =>
|
_ map { user =>
|
||||||
Streamer.WithUserAndStream(s.streamer, user, s.some)
|
Streamer.WithUserAndStream(s.streamer, user, s.some)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def withUsers(live: LiveStreams): Fu[List[Streamer.WithUserAndStream]] =
|
def withUsers(live: LiveStreams): Fu[List[Streamer.WithUserAndStream]] =
|
||||||
live.streams.map(withUser).sequenceFu.map(_.flatten)
|
live.streams.map(withUser).sequenceFu.dmap(_.flatten)
|
||||||
|
|
||||||
def allListedIds: Fu[Set[Streamer.Id]] = listedIdsCache.get
|
def allListedIds: Fu[Set[Streamer.Id]] = listedIdsCache.get
|
||||||
|
|
||||||
|
@ -62,11 +62,11 @@ final class StreamerApi(
|
||||||
coll.ext
|
coll.ext
|
||||||
.find($inIds(ids))
|
.find($inIds(ids))
|
||||||
.sort($doc("seenAt" -> -1))
|
.sort($doc("seenAt" -> -1))
|
||||||
.list[Bdoc](max) map {
|
.list[Bdoc](max) dmap {
|
||||||
_ flatMap {
|
_ flatMap {
|
||||||
_.getAsOpt[Streamer.Id]("_id")
|
_.getAsOpt[Streamer.Id]("_id")
|
||||||
}
|
}
|
||||||
} map (_.toSet)
|
} dmap (_.toSet)
|
||||||
|
|
||||||
def update(prev: Streamer, data: StreamerForm.UserData, asMod: Boolean): Fu[Streamer.ModChange] = {
|
def update(prev: Streamer, data: StreamerForm.UserData, asMod: Boolean): Fu[Streamer.ModChange] = {
|
||||||
val streamer = data(prev, asMod)
|
val streamer = data(prev, asMod)
|
||||||
|
@ -156,8 +156,6 @@ final class StreamerApi(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private def withUser(user: User)(streamer: Streamer) = Streamer.WithUser(streamer, user)
|
|
||||||
|
|
||||||
private def selectListedApproved = $doc(
|
private def selectListedApproved = $doc(
|
||||||
"listed" -> true,
|
"listed" -> true,
|
||||||
"approval.granted" -> true
|
"approval.granted" -> true
|
||||||
|
|
|
@ -11,7 +11,7 @@ final class StreamerPager(
|
||||||
coll: Coll,
|
coll: Coll,
|
||||||
userRepo: UserRepo,
|
userRepo: UserRepo,
|
||||||
maxPerPage: lila.common.config.MaxPerPage
|
maxPerPage: lila.common.config.MaxPerPage
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import BsonHandlers._
|
import BsonHandlers._
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,8 @@ final private class Streaming(
|
||||||
|
|
||||||
private var liveStreams = LiveStreams(Nil)
|
private var liveStreams = LiveStreams(Nil)
|
||||||
|
|
||||||
|
implicit def ec = context.dispatcher
|
||||||
|
|
||||||
def receive = {
|
def receive = {
|
||||||
|
|
||||||
case Streaming.Get => sender ! liveStreams
|
case Streaming.Get => sender ! liveStreams
|
||||||
|
|
|
@ -17,7 +17,7 @@ final class Env(
|
||||||
chapterRepo: lila.study.ChapterRepo,
|
chapterRepo: lila.study.ChapterRepo,
|
||||||
pager: lila.study.StudyPager,
|
pager: lila.study.StudyPager,
|
||||||
makeClient: Index => ESClient
|
makeClient: Index => ESClient
|
||||||
)(implicit system: ActorSystem, mat: akka.stream.Materializer) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem, mat: akka.stream.Materializer) {
|
||||||
|
|
||||||
private val client = makeClient(Index("study"))
|
private val client = makeClient(Index("study"))
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@ final class StudySearchApi(
|
||||||
indexThrottler: ActorRef,
|
indexThrottler: ActorRef,
|
||||||
studyRepo: StudyRepo,
|
studyRepo: StudyRepo,
|
||||||
chapterRepo: ChapterRepo
|
chapterRepo: ChapterRepo
|
||||||
)(implicit system: ActorSystem, mat: akka.stream.Materializer)
|
)(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem, mat: akka.stream.Materializer)
|
||||||
extends SearchReadApi[Study, Query] {
|
extends SearchReadApi[Study, Query] {
|
||||||
|
|
||||||
def search(query: Query, from: From, size: Size) =
|
def search(query: Query, from: From, size: Size) =
|
||||||
|
@ -27,7 +27,7 @@ final class StudySearchApi(
|
||||||
studyRepo byOrderedIds res.ids.map(Study.Id.apply)
|
studyRepo byOrderedIds res.ids.map(Study.Id.apply)
|
||||||
}
|
}
|
||||||
|
|
||||||
def count(query: Query) = client.count(query) map (_.count)
|
def count(query: Query) = client.count(query) dmap (_.count)
|
||||||
|
|
||||||
def store(study: Study) = fuccess {
|
def store(study: Study) = fuccess {
|
||||||
indexThrottler ! LateMultiThrottler.work(
|
indexThrottler ! LateMultiThrottler.work(
|
||||||
|
|
|
@ -18,7 +18,7 @@ final class Env(
|
||||||
appConfig: Configuration,
|
appConfig: Configuration,
|
||||||
makeClient: Index => ESClient,
|
makeClient: Index => ESClient,
|
||||||
teamRepo: lila.team.TeamRepo
|
teamRepo: lila.team.TeamRepo
|
||||||
)(implicit system: ActorSystem) {
|
)(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem) {
|
||||||
|
|
||||||
private val config = appConfig.get[TeamSearchConfig]("teamSearch")(AutoConfig.loader)
|
private val config = appConfig.get[TeamSearchConfig]("teamSearch")(AutoConfig.loader)
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@ import lila.team.{ Team, TeamRepo }
|
||||||
final class TeamSearchApi(
|
final class TeamSearchApi(
|
||||||
client: ESClient,
|
client: ESClient,
|
||||||
teamRepo: TeamRepo
|
teamRepo: TeamRepo
|
||||||
)(implicit mat: akka.stream.Materializer)
|
)(implicit ec: scala.concurrent.ExecutionContext, mat: akka.stream.Materializer)
|
||||||
extends SearchReadApi[Team, Query] {
|
extends SearchReadApi[Team, Query] {
|
||||||
|
|
||||||
def search(query: Query, from: From, size: Size) =
|
def search(query: Query, from: From, size: Size) =
|
||||||
|
@ -17,7 +17,7 @@ final class TeamSearchApi(
|
||||||
teamRepo byOrderedIds res.ids
|
teamRepo byOrderedIds res.ids
|
||||||
}
|
}
|
||||||
|
|
||||||
def count(query: Query) = client.count(query) map (_.count)
|
def count(query: Query) = client.count(query) dmap (_.count)
|
||||||
|
|
||||||
def store(team: Team) = client.store(Id(team.id), toDoc(team))
|
def store(team: Team) = client.store(Id(team.id), toDoc(team))
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ final class EntryApi(
|
||||||
coll: Coll,
|
coll: Coll,
|
||||||
userMax: Max,
|
userMax: Max,
|
||||||
asyncCache: lila.memo.AsyncCache.Builder
|
asyncCache: lila.memo.AsyncCache.Builder
|
||||||
) {
|
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||||
|
|
||||||
import Entry._
|
import Entry._
|
||||||
|
|
||||||
|
@ -36,8 +36,7 @@ final class EntryApi(
|
||||||
projection.some
|
projection.some
|
||||||
)
|
)
|
||||||
.sort($sort desc "date")
|
.sort($sort desc "date")
|
||||||
.cursor[Entry](ReadPreference.secondaryPreferred)
|
.vector[Entry](max.value, ReadPreference.secondaryPreferred)
|
||||||
.gather[Vector](max.value)
|
|
||||||
|
|
||||||
def findRecent(typ: String, since: DateTime, max: Max) =
|
def findRecent(typ: String, since: DateTime, max: Max) =
|
||||||
coll
|
coll
|
||||||
|
@ -46,8 +45,7 @@ final class EntryApi(
|
||||||
projection.some
|
projection.some
|
||||||
)
|
)
|
||||||
.sort($sort desc "date")
|
.sort($sort desc "date")
|
||||||
.cursor[Entry](ReadPreference.secondaryPreferred)
|
.vector[Entry](max.value, ReadPreference.secondaryPreferred)
|
||||||
.gather[Vector](max.value)
|
|
||||||
|
|
||||||
def channelUserIdRecentExists(channel: String, userId: User.ID): Fu[Boolean] =
|
def channelUserIdRecentExists(channel: String, userId: User.ID): Fu[Boolean] =
|
||||||
coll.countSel(
|
coll.countSel(
|
||||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue