formatting standards
parent
4303710792
commit
3a956b2cf9
|
@ -27,13 +27,13 @@ object Mod extends LilaController {
|
|||
|
||||
def publicChat = Secure(_.ChatTimeout) { implicit ctx =>
|
||||
_ =>
|
||||
val tourChats = Env.mod.publicChat.tournamentChats
|
||||
val simulChats = Env.mod.publicChat.simulChats
|
||||
val tourChats = Env.mod.publicChat.tournamentChats
|
||||
val simulChats = Env.mod.publicChat.simulChats
|
||||
|
||||
tourChats zip simulChats map {
|
||||
case (tournamentsAndChats, simulsAndChats) =>
|
||||
Ok (html.mod.publicChat(tournamentsAndChats, simulsAndChats))
|
||||
}
|
||||
tourChats zip simulChats map {
|
||||
case (tournamentsAndChats, simulsAndChats) =>
|
||||
Ok(html.mod.publicChat(tournamentsAndChats, simulsAndChats))
|
||||
}
|
||||
}
|
||||
|
||||
def booster(username: String) = Secure(_.MarkBooster) { _ =>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
@(tourChats : List[(lila.tournament.Tournament, lila.chat.UserChat)],
|
||||
simulChats: List[(lila.simul.Simul, lila.chat.UserChat)])(implicit ctx: Context)
|
||||
simulChats: List[(lila.simul.Simul, lila.chat.UserChat)])(implicit ctx: Context)
|
||||
|
||||
@mod.layout(
|
||||
title = "Public Chats",
|
||||
|
@ -8,49 +8,49 @@ moreCss = cssTag("mod-communication.css"),
|
|||
moreJs = jsTag("public-chat.js")) {
|
||||
|
||||
<div id="communication" class="content_box">
|
||||
<h2>Tournament Chats</h2>
|
||||
<div class="player_chats">
|
||||
<h2>Tournament Chats</h2>
|
||||
<div class="player_chats">
|
||||
@tourChats.map {
|
||||
case (tournament, chat) => {
|
||||
<div class="game">
|
||||
<a class="title" href="@routes.Tournament.show(tournament.id)">
|
||||
@tournament.name
|
||||
</a>
|
||||
<div class="chat">
|
||||
@chat.lines.filter(_.isVisible).map { line =>
|
||||
<div class="line">
|
||||
@userIdLink(line.author.toLowerCase.some, withOnline = false, withTitle = false)
|
||||
@line.text
|
||||
</div>
|
||||
}
|
||||
<a class="title" href="@routes.Tournament.show(tournament.id)">
|
||||
@tournament.name
|
||||
</a>
|
||||
<div class="chat">
|
||||
@chat.lines.filter(_.isVisible).map { line =>
|
||||
<div class="line">
|
||||
@userIdLink(line.author.toLowerCase.some, withOnline = false, withTitle = false)
|
||||
@line.text
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
<div>
|
||||
<h2>Simul Chats</h2>
|
||||
<div class="player_chats">
|
||||
|
||||
@simulChats.map {
|
||||
case (simul, chat) => {
|
||||
<div class="game">
|
||||
<a class="title" href="@routes.Simul.show(simul.id)">
|
||||
@simul.name
|
||||
</a>
|
||||
<div class="chat">
|
||||
@chat.lines.filter(_.isVisible).map { line =>
|
||||
<div class="line">
|
||||
@userIdLink(line.author.toLowerCase.some, withOnline = false, withTitle = false)
|
||||
@line.text
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@simulChats.map {
|
||||
case (simul, chat) => {
|
||||
<div class="game">
|
||||
<a class="title" href="@routes.Simul.show(simul.id)">
|
||||
@simul.name
|
||||
</a>
|
||||
<div class="chat">
|
||||
@chat.lines.filter(_.isVisible).map { line =>
|
||||
<div class="line">
|
||||
@userIdLink(line.author.toLowerCase.some, withOnline = false, withTitle = false)
|
||||
@line.text
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ final class Env(
|
|||
reportColl = reportColl,
|
||||
historyColl = db(CollectionGamingHistory))
|
||||
|
||||
lazy val publicChat = new PublicChat(chatApi,tournament, simul)
|
||||
lazy val publicChat = new PublicChat(chatApi, tournament, simul)
|
||||
|
||||
lazy val search = new UserSearch(
|
||||
securityApi = securityApi,
|
||||
|
|
|
@ -1,53 +1,53 @@
|
|||
package lila.mod
|
||||
|
||||
import lila.tournament.{ Tournament => TournamentModel}
|
||||
import lila.simul.{ Simul => SimulModel}
|
||||
import lila.chat.UserChat
|
||||
import lila.simul.{ Simul => SimulModel }
|
||||
import lila.tournament.{ Tournament => TournamentModel }
|
||||
|
||||
final class PublicChat(chatApi: lila.chat.ChatApi,
|
||||
tournament: lila.tournament.Env,
|
||||
simul: lila.simul.Env) {
|
||||
tournament: lila.tournament.Env,
|
||||
simul: lila.simul.Env) {
|
||||
|
||||
var tournamentApi = tournament.api
|
||||
val simulApi = simul.api
|
||||
var tournamentApi = tournament.api
|
||||
val simulApi = simul.api
|
||||
|
||||
def tournamentChats : Fu[List[(TournamentModel, UserChat)]] =
|
||||
tournamentApi.fetchVisibleTournaments.flatMap {
|
||||
visibleTournaments =>
|
||||
val tournamentList = sortTournamentsByRelevance(visibleTournaments.all)
|
||||
val ids = tournamentList.map(_.id)
|
||||
chatApi.userChat.findAll(ids).map {
|
||||
chats =>
|
||||
chats.map { chat =>
|
||||
tournamentList.find(_.id === chat.id).map( tour => (tour,chat))
|
||||
}.flatten
|
||||
}
|
||||
def tournamentChats: Fu[List[(TournamentModel, UserChat)]] =
|
||||
tournamentApi.fetchVisibleTournaments.flatMap {
|
||||
visibleTournaments =>
|
||||
val tournamentList = sortTournamentsByRelevance(visibleTournaments.all)
|
||||
val ids = tournamentList.map(_.id)
|
||||
chatApi.userChat.findAll(ids).map {
|
||||
chats =>
|
||||
chats.map { chat =>
|
||||
tournamentList.find(_.id === chat.id).map(tour => (tour, chat))
|
||||
}.flatten
|
||||
}
|
||||
}
|
||||
|
||||
def simulChats : Fu[List[(SimulModel, UserChat)]] =
|
||||
fetchVisibleSimuls.flatMap {
|
||||
simuls =>
|
||||
var ids = simuls.map(_.id)
|
||||
chatApi.userChat.findAll(ids).map {
|
||||
chats =>
|
||||
chats.map { chat =>
|
||||
simuls.find(_.id === chat.id).map( simul => (simul,chat))
|
||||
}.flatten
|
||||
}
|
||||
def simulChats: Fu[List[(SimulModel, UserChat)]] =
|
||||
fetchVisibleSimuls.flatMap {
|
||||
simuls =>
|
||||
var ids = simuls.map(_.id)
|
||||
chatApi.userChat.findAll(ids).map {
|
||||
chats =>
|
||||
chats.map { chat =>
|
||||
simuls.find(_.id === chat.id).map(simul => (simul, chat))
|
||||
}.flatten
|
||||
}
|
||||
}
|
||||
|
||||
private def fetchVisibleSimuls : Fu[List[SimulModel]] = {
|
||||
simul.allCreated(true) zip
|
||||
simul.repo.allStarted zip
|
||||
simul.repo.allFinished(5) map {
|
||||
case ((created,started),finished) =>
|
||||
created ::: started ::: finished
|
||||
}
|
||||
}
|
||||
private def fetchVisibleSimuls: Fu[List[SimulModel]] = {
|
||||
simul.allCreated(true) zip
|
||||
simul.repo.allStarted zip
|
||||
simul.repo.allFinished(5) 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[TournamentModel]) : List[TournamentModel] =
|
||||
tournaments.sortBy(-_.nbPlayers)
|
||||
/**
|
||||
* Sort the tournaments by the tournaments most likely to require moderation attention
|
||||
*/
|
||||
private def sortTournamentsByRelevance(tournaments: List[TournamentModel]): List[TournamentModel] =
|
||||
tournaments.sortBy(-_.nbPlayers)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue