<commit_before>package lila.mod

import lila.chat.UserChat
import lila.simul.{ Simul => SimulModel }
import lila.tournament.{ Tournament => TournamentModel }

final class PublicChat(
    chatApi: lila.chat.ChatApi,
    tournamentApi: lila.tournament.TournamentApi,
    simulEnv: lila.simul.Env) {

  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
        }
    }

  private def fetchVisibleSimuls: Fu[List[SimulModel]] = {
    simulEnv.allCreated(true) zip
      simulEnv.repo.allStarted zip
      simulEnv.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)
}
<commit_msg>no longer need to alias models<commit_after>package lila.mod

import lila.chat.UserChat
import lila.simul.Simul
import lila.tournament.Tournament

final class PublicChat(
    chatApi: lila.chat.ChatApi,
    tournamentApi: lila.tournament.TournamentApi,
    simulEnv: lila.simul.Env) {

  def tournamentChats: Fu[List[(Tournament, 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[(Simul, 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[Simul]] = {
    simulEnv.allCreated(true) zip
      simulEnv.repo.allStarted zip
      simulEnv.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[Tournament]): List[Tournament] =
    tournaments.sortBy(-_.nbPlayers)
}

{'fraction_non_alphanumeric': 0.11539648256710892, 'fraction_numerical': 0.000617093489663684, 'mean_word_length': 2.6345291479820627, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4723463', 'n_tokens_mistral': 1046, 'n_tokens_neox': 994, 'n_words': 191}