diff --git a/conf/base.conf b/conf/base.conf index 93cf5b817e..1a1e58d24d 100644 --- a/conf/base.conf +++ b/conf/base.conf @@ -266,9 +266,6 @@ shutup { playban { collection.playban = playban } -perfStat { - collection.perf_stat = "perf_stat" -} push { collection { device = push_device diff --git a/modules/perfStat/src/main/Env.scala b/modules/perfStat/src/main/Env.scala index e76117b014..70918cbe8a 100644 --- a/modules/perfStat/src/main/Env.scala +++ b/modules/perfStat/src/main/Env.scala @@ -2,27 +2,27 @@ package lila.perfStat import akka.actor._ import com.softwaremill.macwire._ +import com.softwaremill.tagging._ import play.api.Configuration import lila.common.config._ @Module final class Env( - appConfig: Configuration, lightUser: lila.common.LightUser.GetterSync, lightUserApi: lila.user.LightUserApi, gameRepo: lila.game.GameRepo, userRepo: lila.user.UserRepo, rankingsOf: lila.user.RankingsOf, rankingApi: lila.user.RankingApi, - db: lila.db.Db + yoloDb: lila.db.AsyncDb @@ lila.db.YoloDb )(implicit ec: scala.concurrent.ExecutionContext, system: ActorSystem ) { private lazy val storage = new PerfStatStorage( - coll = db(appConfig.get[CollName]("perfStat.collection.perf_stat")) + coll = yoloDb(CollName("perf_stat")).failingSilently() ) lazy val indexer = wire[PerfStatIndexer] diff --git a/modules/perfStat/src/main/PerfStatStorage.scala b/modules/perfStat/src/main/PerfStatStorage.scala index aa476cedab..2a2a7761cf 100644 --- a/modules/perfStat/src/main/PerfStatStorage.scala +++ b/modules/perfStat/src/main/PerfStatStorage.scala @@ -2,11 +2,12 @@ package lila.perfStat import reactivemongo.api.bson._ +import lila.db.AsyncCollFailingSilently import lila.db.dsl._ import lila.rating.BSONHandlers.perfTypeIdHandler import lila.rating.PerfType -final class PerfStatStorage(coll: Coll)(implicit ec: scala.concurrent.ExecutionContext) { +final class PerfStatStorage(coll: AsyncCollFailingSilently)(implicit ec: scala.concurrent.ExecutionContext) { implicit private val UserIdBSONHandler = stringAnyValHandler[UserId](_.value, UserId.apply) implicit private val RatingAtBSONHandler = Macros.handler[RatingAt] @@ -22,13 +23,12 @@ final class PerfStatStorage(coll: Coll)(implicit ec: scala.concurrent.ExecutionC implicit private val PerfStatBSONHandler = Macros.handler[PerfStat] def find(userId: String, perfType: PerfType): Fu[Option[PerfStat]] = - coll.byId[PerfStat](PerfStat.makeId(userId, perfType)) + coll(_.byId[PerfStat](PerfStat.makeId(userId, perfType))) def insert(perfStat: PerfStat): Funit = - coll.insert.one(perfStat).void - - def update(a: PerfStat, b: PerfStat): Funit = { + coll(_.insert.one(perfStat).void) + def update(a: PerfStat, b: PerfStat): Funit = coll { c => val sets = $doc( docDiff(a.count, b.count).mapKeys(k => s"count.$k").toList ::: List( @@ -77,7 +77,7 @@ final class PerfStatStorage(coll: Coll)(implicit ec: scala.concurrent.ExecutionC ).flatten ) - coll.update + c.update .one($id(a.id), $doc("$set" -> sets)) .void }