<commit_before>package lila.app

import akka.actor._
import com.typesafe.config.Config

final class Env(
    config: Config,
    system: ActorSystem,
    appPath: String) {

  val CliUsername = config getString "cli.username"

  private val RendererName = config getString "app.renderer.name"
  private val RouterName = config getString "app.router.name"
  private val WebPath = config getString "app.web_path"
  private val TimeagoLocalesPath = config getString "app.timeago_locales_path"

  def timeagoLocalesPath = appPath + "/" + TimeagoLocalesPath

  lazy val preloader = new mashup.Preload(
    lobby = Env.lobby.lobby,
    history = Env.lobby.history,
    featured = Env.game.featured,
    recentGames = () ⇒ Env.timeline.getter.recentGames,
    timelineEntries = Env.timeline.getter.userEntries _)

  lazy val userInfo = mashup.UserInfo(
    countUsers = () ⇒ Env.user.countEnabled,
    bookmarkApi = Env.bookmark.api,
    eloCalculator = Env.round.eloCalculator,
    relationApi = Env.relation.api,
    gameCached = Env.game.cached,
    postApi = Env.forum.postApi,
    getRank = Env.user.ranking.get) _

  if (config getBoolean "ai.stress") {
    new AiStresser(Env.ai, system).apply
  }

  system.actorOf(Props(new actor.Renderer), name = RendererName)

  system.actorOf(Props(new actor.Router(
    baseUrl = Env.api.Net.BaseUrl,
    protocol = Env.api.Net.Protocol,
    domain = Env.api.Net.Domain
  )), name = RouterName)

  if (!Env.ai.isServer) {
    loginfo("[boot] Preloading modules")
    (Env.site,
      Env.tournament,
      Env.lobby,
      Env.game,
      Env.ai,
      Env.setup,
      Env.round,
      Env.team,
      Env.message,
      Env.socket,
      Env.timeline,
      Env.gameSearch,
      Env.teamSearch,
      Env.forumSearch,
      Env.relation)
    loginfo("[boot] Preloading complete")
  }

  if (Env.ai.isServer) println("Running as AI server")
}

object Env {

  lazy val current = "[boot] app" describes new Env(
    config = lila.common.PlayApp.loadConfig,
    system = lila.common.PlayApp.system,<commit_msg>preload more modules<commit_after>package lila.app

import akka.actor._
import com.typesafe.config.Config

final class Env(
    config: Config,
    system: ActorSystem,
    appPath: String) {

  val CliUsername = config getString "cli.username"

  private val RendererName = config getString "app.renderer.name"
  private val RouterName = config getString "app.router.name"
  private val WebPath = config getString "app.web_path"
  private val TimeagoLocalesPath = config getString "app.timeago_locales_path"

  def timeagoLocalesPath = appPath + "/" + TimeagoLocalesPath

  lazy val preloader = new mashup.Preload(
    lobby = Env.lobby.lobby,
    history = Env.lobby.history,
    featured = Env.game.featured,
    recentGames = () ⇒ Env.timeline.getter.recentGames,
    timelineEntries = Env.timeline.getter.userEntries _)

  lazy val userInfo = mashup.UserInfo(
    countUsers = () ⇒ Env.user.countEnabled,
    bookmarkApi = Env.bookmark.api,
    eloCalculator = Env.round.eloCalculator,
    relationApi = Env.relation.api,
    gameCached = Env.game.cached,
    postApi = Env.forum.postApi,
    getRank = Env.user.ranking.get) _

  if (config getBoolean "ai.stress") {
    new AiStresser(Env.ai, system).apply
  }

  system.actorOf(Props(new actor.Renderer), name = RendererName)

  system.actorOf(Props(new actor.Router(
    baseUrl = Env.api.Net.BaseUrl,
    protocol = Env.api.Net.Protocol,
    domain = Env.api.Net.Domain
  )), name = RouterName)

  if (!Env.ai.isServer) {
    loginfo("[boot] Preloading modules")
    (Env.site,
      Env.tournament,
      Env.lobby,
      Env.game,
      Env.ai,
      Env.setup,
      Env.round,
      Env.team,
      Env.message,
      Env.socket,
      Env.timeline,
      Env.gameSearch,
      Env.teamSearch,
      Env.forumSearch,
      Env.relation,
      Env.report,
      Env.notification,
      Env.bookmark)
    loginfo("[boot] Preloading complete")
  }

  if (Env.ai.isServer) println("Running as AI server")
}

object Env {

  lazy val current = "[boot] app" describes new Env(
    config = lila.common.PlayApp.loadConfig,
    system = lila.common.PlayApp.system,
{'fraction_non_alphanumeric': 0.11081794195250659, 'fraction_numerical': 0.0, 'mean_word_length': 3.052478134110787, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6559386', 'n_tokens_mistral': 1427, 'n_tokens_neox': 1396, 'n_words': 298}