diff --git a/app/controllers/Mod.scala b/app/controllers/Mod.scala index 2ba66c1da5..593d30143b 100644 --- a/app/controllers/Mod.scala +++ b/app/controllers/Mod.scala @@ -59,8 +59,8 @@ final class Mod( def publicChat = Secure(_.PublicChatView) { implicit ctx => _ => - env.mod.publicChat.all map { case (tournamentsAndChats, simulsAndChats) => - Ok(html.mod.publicChat(tournamentsAndChats, simulsAndChats)) + env.mod.publicChat.all map { case (tournamentsAndChats, swissesAndChats) => + Ok(html.mod.publicChat(tournamentsAndChats, swissesAndChats)) } } diff --git a/app/views/mod/publicChat.scala b/app/views/mod/publicChat.scala index bb00d3b0fe..a70db3eac2 100644 --- a/app/views/mod/publicChat.scala +++ b/app/views/mod/publicChat.scala @@ -13,7 +13,7 @@ object publicChat { def apply( tourChats: List[(lila.tournament.Tournament, UserChat)], - simulChats: List[(lila.simul.Simul, UserChat)] + swissChats: List[(lila.swiss.Swiss, UserChat)] )(implicit ctx: Context) = views.html.base.layout( title = "Public Chats", @@ -33,11 +33,11 @@ object publicChat { } ), div( - h2("Simul Chats"), + h2("Swiss Chats"), div(cls := "player_chats")( - simulChats.map { case (simul, chat) => - div(cls := "game", dataChan := "simul", dataRoom := simul.id)( - chatOf(routes.Simul.show(simul.id), simul.name, chat) + swissChats.map { case (swiss, chat) => + div(cls := "game", dataChan := "swiss", dataRoom := swiss.id.value)( + chatOf(routes.Swiss.show(swiss.id.value), swiss.name, chat) ) } ) diff --git a/build.sbt b/build.sbt index 175cbb7770..a5a4340717 100644 --- a/build.sbt +++ b/build.sbt @@ -181,7 +181,7 @@ lazy val event = module("event", ) lazy val mod = module("mod", - Seq(common, db, user, hub, security, tournament, simul, game, analyse, evaluation, report, notifyModule, history, perfStat, irc), + Seq(common, db, user, hub, security, tournament, swiss, game, analyse, evaluation, report, notifyModule, history, perfStat, irc), reactivemongo.bundle ) @@ -226,7 +226,7 @@ lazy val pool = module("pool", ) lazy val activity = module("activity", - Seq(common, game, analyse, user, forum, study, pool, puzzle, tournament, swiss, practice, team, ublog), + Seq(common, game, analyse, user, forum, study, pool, puzzle, tournament, simul, swiss, practice, team, ublog), reactivemongo.bundle ) diff --git a/modules/mod/src/main/Env.scala b/modules/mod/src/main/Env.scala index 4fa3ea386d..636f7ed0c7 100644 --- a/modules/mod/src/main/Env.scala +++ b/modules/mod/src/main/Env.scala @@ -20,10 +20,10 @@ final class Env( lightUserApi: lila.user.LightUserApi, securityApi: lila.security.SecurityApi, tournamentApi: lila.tournament.TournamentApi, + swissFeature: lila.swiss.SwissFeature, gameRepo: lila.game.GameRepo, analysisRepo: lila.analyse.AnalysisRepo, userRepo: lila.user.UserRepo, - simulEnv: lila.simul.Env, chatApi: lila.chat.ChatApi, notifyApi: lila.notify.NotifyApi, historyApi: lila.history.HistoryApi, diff --git a/modules/mod/src/main/PublicChat.scala b/modules/mod/src/main/PublicChat.scala index 580fbfa5f4..9a815fdcd5 100644 --- a/modules/mod/src/main/PublicChat.scala +++ b/modules/mod/src/main/PublicChat.scala @@ -2,19 +2,19 @@ package lila.mod import lila.chat.{ Chat, UserChat } import lila.report.Suspect -import lila.simul.Simul +import lila.swiss.Swiss import lila.tournament.Tournament import lila.user.{ User, UserRepo } final class PublicChat( chatApi: lila.chat.ChatApi, tournamentApi: lila.tournament.TournamentApi, - simulEnv: lila.simul.Env, + swissFeature: lila.swiss.SwissFeature, userRepo: UserRepo )(implicit ec: scala.concurrent.ExecutionContext) { - def all: Fu[(List[(Tournament, UserChat)], List[(Simul, UserChat)])] = - tournamentChats zip simulChats + def all: Fu[(List[(Tournament, UserChat)], List[(Swiss, UserChat)])] = + tournamentChats zip swissChats def deleteAll(userId: User.ID): Funit = userRepo byId userId map2 Suspect flatMap { _ ?? deleteAll } @@ -30,32 +30,25 @@ final class PublicChat( private def tournamentChats: Fu[List[(Tournament, UserChat)]] = tournamentApi.fetchVisibleTournaments.flatMap { visibleTournaments => - val ids = visibleTournaments.all.map(_.id) map Chat.Id.apply + val ids = visibleTournaments.all.map(_.id) map Chat.Id chatApi.userChat.findAll(ids).map { chats => chats.flatMap { chat => - visibleTournaments.all.find(_.id == chat.id.value).map(tour => (tour, chat)) + visibleTournaments.all.find(_.id == chat.id.value).map(_ -> chat) } } map sortTournamentsByRelevance } - private def simulChats: Fu[List[(Simul, UserChat)]] = - fetchVisibleSimuls.flatMap { simuls => - val ids = simuls.map(_.id) map Chat.Id.apply + private def swissChats: Fu[List[(Swiss, UserChat)]] = + swissFeature.get(Nil).flatMap { swisses => + val all = swisses.created ::: swisses.started + val ids = all.map(_.id.value) map Chat.Id chatApi.userChat.findAll(ids).map { chats => chats.flatMap { chat => - simuls.find(_.id == chat.id.value).map(simul => (simul, chat)) + all.find(_.id.value == chat.id.value).map(_ -> chat) } } } - private def fetchVisibleSimuls: Fu[List[Simul]] = { - simulEnv.allCreatedFeaturable.get {} zip - simulEnv.repo.allStarted zip - simulEnv.repo.allFinishedFeaturable(3) map { case ((created, started), finished) => - created ::: started ::: finished - } - } - /** Sort the tournaments by the tournaments most likely to require moderation attention */ private def sortTournamentsByRelevance(tournaments: List[(Tournament, UserChat)]) =