getting it to run WIP

rm0193-mapreduce
Thibault Duplessis 2019-12-05 11:42:46 -06:00
parent c12b81b3df
commit 2d23da2898
13 changed files with 37 additions and 81 deletions

View File

@ -24,7 +24,11 @@ class LilaComponents(ctx: Context) extends BuiltInComponentsFromContext(ctx)
implicit def system = actorSystem
implicit def ws = wsClient
def cookieBacker: SessionCookieBaker = injector.instanceOf[SessionCookieBaker]
def cookieBacker: SessionCookieBaker = new DefaultSessionCookieBaker(
httpConfiguration.session,
httpConfiguration.secret,
new libs.crypto.CookieSignerProvider(httpConfiguration.secret).get
)
lazy val boot: lila.app.EnvBoot = wire[lila.app.EnvBoot]
lazy val env: lila.app.Env = boot.env

View File

@ -12,14 +12,14 @@ trait AssetHelper { self: I18nHelper with SecurityHelper =>
def isProd: Boolean
val siteDomain = env.net.domain
val assetDomain = env.net.assetDomain
val socketDomain = env.net.socketDomain
val vapidPublicKey = env.push.vapidPublicKey
def netDomain: lila.common.config.NetDomain
lazy val assetDomain = env.net.assetDomain
lazy val socketDomain = env.net.socketDomain
lazy val vapidPublicKey = env.push.vapidPublicKey
val sameAssetDomain = siteDomain.value == assetDomain.value
lazy val sameAssetDomain = netDomain.value == assetDomain.value
val assetBaseUrl = s"//$assetDomain"
lazy val assetBaseUrl = s"//$assetDomain"
def assetVersion = AssetVersion.current
@ -53,7 +53,7 @@ trait AssetHelper { self: I18nHelper with SecurityHelper =>
src := assetUrl(path)
)
val jQueryTag = raw {
lazy val jQueryTag = raw {
s"""<script src="${staticUrl("javascripts/vendor/jquery.min.js")}"></script>"""
}
@ -67,23 +67,23 @@ trait AssetHelper { self: I18nHelper with SecurityHelper =>
def captchaTag = jsAt(s"compiled/captcha.js")
val highchartsLatestTag = raw {
lazy val highchartsLatestTag = raw {
s"""<script src="${staticUrl("vendor/highcharts-4.2.5/highcharts.js")}"></script>"""
}
val highchartsMoreTag = raw {
lazy val highchartsMoreTag = raw {
s"""<script src="${staticUrl("vendor/highcharts-4.2.5/highcharts-more.js")}"></script>"""
}
val fingerprintTag = raw {
lazy val fingerprintTag = raw {
s"""<script async src="${staticUrl("javascripts/vendor/fp2.min.js")}"></script>"""
}
val flatpickrTag = raw {
lazy val flatpickrTag = raw {
s"""<script defer src="${staticUrl("javascripts/vendor/flatpickr.min.js")}"></script>"""
}
val nonAsyncFlatpickrTag = raw {
lazy val nonAsyncFlatpickrTag = raw {
s"""<script defer src="${staticUrl("javascripts/vendor/flatpickr.min.js")}"></script>"""
}
@ -91,7 +91,7 @@ trait AssetHelper { self: I18nHelper with SecurityHelper =>
"""$(function() { setTimeout(function() { $(".flatpickr").flatpickr(); }, 2000) });"""
}
val infiniteScrollTag = jsTag("vendor/jquery.infinitescroll.min.js")
lazy val infiniteScrollTag = jsTag("vendor/jquery.infinitescroll.min.js")
def prismicJs(implicit ctx: Context): Frag = raw {
isGranted(_.Prismic) ?? {

View File

@ -33,17 +33,17 @@ object Environment
type FormWithCaptcha = (play.api.data.Form[_], lila.common.Captcha)
def netDomain = env.net.domain.value
def netBaseUrl = env.net.baseUrl.value
def isGloballyCrawlable = env.net.crawlable
lazy val netDomain = env.net.domain
def isProd = env.isProd
val isStage = env.isStage
def isStage = env.isStage
def apiVersion = lila.api.Mobile.Api.currentVersion
val explorerEndpoint = env.explorerEndpoint
val tablebaseEndpoint = env.tablebaseEndpoint
lazy val explorerEndpoint = env.explorerEndpoint
lazy val tablebaseEndpoint = env.tablebaseEndpoint
def contactEmail = env.net.email

View File

@ -6,8 +6,6 @@ import ui.ScalatagsTemplate._
trait StringHelper { self: NumberHelper =>
def netDomain: String
val slugify = lila.common.String.slugify _
def shorten(text: String, length: Int, sep: String = "…") = lila.common.String.shorten(text, length, sep)

View File

@ -154,7 +154,6 @@ search {
}
teamSearch {
index = team
paginator.max_per_page = ${team.paginator.max_per_page}
actor.name = team-search
}
relation {
@ -172,7 +171,6 @@ relation {
}
bookmark {
collection.bookmark = bookmark
paginator.max_per_page = ${game.paginator.max_per_page}
actor.name = bookmark
}
geoip {
@ -419,10 +417,6 @@ setup.max_playing = 200
evalCache {
collection.evalCache = eval_cache
}
studySearch {
index = study
paginator.max_per_page = ${study.paginator.max_per_page}
}
user {
cached.nb.ttl = 10 minutes
online.ttl = 7 seconds

View File

@ -1,7 +1,6 @@
package lila.activity
import org.joda.time.{ DateTime, Interval }
import scala.math.Ordering.Float.TotalOrdering
import lila.db.dsl._
import lila.game.LightPov

View File

@ -6,13 +6,12 @@ import io.methvin.play.autoconfig._
import play.api.Configuration
import lila.common.config._
import lila.common.tagging._
import lila.hub.actorApi.bookmark._
@Module
private final class BookmarkConfig(
@ConfigName("collection.bookmark") val bookmarkCollName: CollName,
@ConfigName("paginator.maxPerPage") val paginatorMaxPerPage: MaxPerPage,
@ConfigName("paginator.max_per_page") val paginatorMaxPerPage: MaxPerPage,
@ConfigName("actor.name") val actorName: String
)

View File

@ -12,7 +12,10 @@ final class Env(
appConfig: Configuration,
ws: WSClient
) {
appConfig.underlying.getString("net.asset.domain")
val c = appConfig.underlying.getConfig("net")
println(c)
println(c getString "asset.domain")
val netConfig = appConfig.get[NetConfig]("net")
def netDomain = netConfig.domain

View File

@ -31,7 +31,6 @@ object config {
domain: NetDomain,
protocol: String,
@ConfigName("base_url") baseUrl: BaseUrl,
port: Int,
@ConfigName("asset.domain") assetDomain: AssetDomain,
@ConfigName("socket.domain") socketDomain: String,
crawlable: Boolean,
@ -57,7 +56,11 @@ object config {
c.getConfigList(k).asScala.toList map { l.load(_) }
}
def strLoader[A](f: String => A): ConfigLoader[A] = ConfigLoader(_.getString) map f
def strLoader[A](f: String => A): ConfigLoader[A] = ConfigLoader(c => s => {
println(c)
println(s"{$s}")
c.getString(s)
}) map f
def intLoader[A](f: Int => A): ConfigLoader[A] = ConfigLoader(_.getInt) map f
def durationLoader[A](f: FiniteDuration => A): ConfigLoader[A] = ConfigLoader(_.duration) map f
}

View File

@ -1,34 +0,0 @@
package lila.common
/**
* Tag instances with arbitrary types. The tags are usually empty `trait`s. Tags have no runtime overhead and are only
* used at compile-time for additional type safety.
*
* For example:
*
* {{{
* class Berry()
*
* trait Black
* trait Blue
*
* val berry = new Berry()
* val blackBerry: Berry @@ Black = berry.taggedWith[Black]
* val blueBerry: Berry @@ Blue = berry.taggedWith[Blue]
*
* // compile error: val anotherBlackBerry: Berry @@ Black = blueBerry
* }}}
*
* Original idea by Miles Sabin, see: https://gist.github.com/milessabin/89c9b47a91017973a35f
*/
package object tagging {
trait Tag[+U] extends Any { type Tag <: U }
type @@[+T, +U] = T with Tag[U]
type Tagged[+T, +U] = T with Tag[U]
implicit class Tagger[T](val t: T) extends AnyVal {
def taggedWith[U]: T @@ U = t.asInstanceOf[T @@ U]
}
implicit class AndTagger[T, U](val t: T @@ U) extends AnyVal {
def andTaggedWith[V]: T @@ (U with V) = t.asInstanceOf[T @@ (U with V)]
}
}

View File

@ -15,7 +15,7 @@ private class GameConfig(
@ConfigName("collection.game") val gameColl: CollName,
@ConfigName("collection.crosstable") val crosstableColl: CollName,
@ConfigName("collection.matchup") val matchupColl: CollName,
@ConfigName("paginator.maxPerPage") val paginatorMaxPerPage: MaxPerPage,
@ConfigName("paginator.max_per_page") val paginatorMaxPerPage: MaxPerPage,
@ConfigName("captcher.name") val captcherName: String,
@ConfigName("captcher.duration") val captcherDuration: FiniteDuration,
val uciMemoTtl: FiniteDuration,

View File

@ -2,8 +2,6 @@ package lila.studySearch
import akka.actor._
import com.softwaremill.macwire._
import io.methvin.play.autoconfig._
import play.api.Configuration
import scala.concurrent.duration._
import lila.common.Bus
@ -15,23 +13,14 @@ import lila.search._
import lila.study.Study
import lila.user.User
@Module
private class StudySearchConfig(
@ConfigName("index.name") val indexName: String,
@ConfigName("paginator.max_per_page") val maxPerPage: MaxPerPage
)
final class Env(
appConfig: Configuration,
studyRepo: lila.study.StudyRepo,
chapterRepo: lila.study.ChapterRepo,
pager: lila.study.StudyPager,
makeClient: Index => ESClient
)(implicit system: ActorSystem, mat: akka.stream.Materializer) {
private val config = appConfig.get[StudySearchConfig]("studySearch")(AutoConfig.loader)
private val client = makeClient(Index(config.indexName))
private val client = makeClient(Index("study"))
private val indexThrottler = system.actorOf(Props(new LateMultiThrottler(
executionTimeout = 3.seconds.some,
@ -50,7 +39,7 @@ final class Env(
pager.withChapters(_, Study.maxChapters)
} mapFutureList pager.withLiking(me),
currentPage = page,
maxPerPage = config.maxPerPage
maxPerPage = MaxPerPage(15)
)
def cli = new lila.common.Cli {

View File

@ -11,7 +11,6 @@ import lila.search._
@Module
private class TeamSearchConfig(
@ConfigName("index.name") val indexName: String,
@ConfigName("paginator.max_per_page") val maxPerPage: MaxPerPage,
@ConfigName("actor.name") val actorName: String
)
@ -23,6 +22,8 @@ final class Env(
private val config = appConfig.get[TeamSearchConfig]("teamSearch")(AutoConfig.loader)
private val maxPerPage = MaxPerPage(15)
private lazy val client = makeClient(Index(config.indexName))
private lazy val paginatorBuilder = wire[lila.search.PaginatorBuilder[lila.team.Team, Query]]