simul hosts get 10,000 homepage impressions a day
parent
237a4c7fe7
commit
c8a1700728
|
@ -102,7 +102,7 @@ object home {
|
|||
events.map(bits.spotlight),
|
||||
!ctx.isBot option frag(
|
||||
lila.tournament.Spotlight.select(tours, ctx.me, 3 - events.size) map { views.html.tournament.homepageSpotlight(_) },
|
||||
simuls.find(_.spotlightable).headOption map views.html.simul.bits.homepageSpotlight
|
||||
simuls.find(_.spotlightable).filter(lila.simul.Env.current.featurable).headOption map views.html.simul.bits.homepageSpotlight
|
||||
)
|
||||
),
|
||||
ctx.me map { u =>
|
||||
|
|
|
@ -449,6 +449,7 @@ simul {
|
|||
created.cache.ttl = 2 seconds
|
||||
history.message.ttl = 20 seconds
|
||||
uid.timeout = 7 seconds # small to avoid missed events
|
||||
feature.views = 10000 # max frontpage views of simul per host per day
|
||||
}
|
||||
forum {
|
||||
topic.max_per_page = 10
|
||||
|
|
|
@ -13,7 +13,8 @@ final class RateLimit[K](
|
|||
duration: Duration,
|
||||
name: String,
|
||||
key: String,
|
||||
enforce: Boolean = true
|
||||
enforce: Boolean = true,
|
||||
log: Boolean = true
|
||||
) {
|
||||
import RateLimit._
|
||||
|
||||
|
@ -43,7 +44,7 @@ final class RateLimit[K](
|
|||
storage.put(k, cost -> makeClearAt)
|
||||
op
|
||||
case _ if enforce =>
|
||||
logger.info(s"$name ($credits/$duration) $k cost: $cost $msg")
|
||||
if (log) logger.info(s"$name ($credits/$duration) $k cost: $cost $msg")
|
||||
monitor()
|
||||
default.zero
|
||||
case _ =>
|
||||
|
|
|
@ -20,15 +20,13 @@ final class Env(
|
|||
asyncCache: lila.memo.AsyncCache.Builder
|
||||
) {
|
||||
|
||||
private val settings = new {
|
||||
val CollectionSimul = config getString "collection.simul"
|
||||
val SequencerTimeout = config duration "sequencer.timeout"
|
||||
val CreatedCacheTtl = config duration "created.cache.ttl"
|
||||
val HistoryMessageTtl = config duration "history.message.ttl"
|
||||
val UidTimeout = config duration "uid.timeout"
|
||||
val SocketTimeout = config duration "socket.timeout"
|
||||
}
|
||||
import settings._
|
||||
private val CollectionSimul = config getString "collection.simul"
|
||||
private val SequencerTimeout = config duration "sequencer.timeout"
|
||||
private val CreatedCacheTtl = config duration "created.cache.ttl"
|
||||
private val HistoryMessageTtl = config duration "history.message.ttl"
|
||||
private val UidTimeout = config duration "uid.timeout"
|
||||
private val SocketTimeout = config duration "socket.timeout"
|
||||
private val FeatureViews = config getInt "feature.views"
|
||||
|
||||
lazy val repo = new SimulRepo(
|
||||
simulColl = simulColl
|
||||
|
@ -110,6 +108,16 @@ final class Env(
|
|||
expireAfter = _.ExpireAfterWrite(CreatedCacheTtl)
|
||||
)
|
||||
|
||||
def featurable(simul: Simul): Boolean = featureLimiter(simul.hostId)(true)
|
||||
|
||||
private val featureLimiter = new lila.memo.RateLimit[lila.user.User.ID](
|
||||
credits = FeatureViews,
|
||||
duration = 24 hours,
|
||||
name = "simul homepage views",
|
||||
key = "simul.feature",
|
||||
log = false
|
||||
)
|
||||
|
||||
def version(simulId: String): Fu[SocketVersion] =
|
||||
socketMap.askIfPresentOrZero[SocketVersion](simulId)(GetVersion)
|
||||
|
||||
|
|
|
@ -125,9 +125,8 @@ case class Simul(
|
|||
private def Created(s: => Simul): Simul = if (isCreated) s else this
|
||||
|
||||
def spotlightable =
|
||||
isCreated &&
|
||||
(hostRating >= 2400 || hostTitle.isDefined) &&
|
||||
!Simul.abusiveHosts(hostId) &&
|
||||
(hostRating >= 2400 || hostTitle.isDefined) &&
|
||||
isCreated &&
|
||||
applicants.size < 80
|
||||
|
||||
def wins = pairings.count(p => p.finished && p.wins.has(false))
|
||||
|
@ -181,6 +180,4 @@ object Simul {
|
|||
text = text,
|
||||
team = team
|
||||
)
|
||||
|
||||
private val abusiveHosts = Set("lance5500")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue