report score threshold dynamic setting
parent
6909f19d0c
commit
08179c5170
|
@ -300,6 +300,7 @@ mod {
|
|||
report {
|
||||
collection.report = report2
|
||||
actor.name = report
|
||||
score.threshold = 50
|
||||
}
|
||||
i18n {
|
||||
web_path.relative = ${app.web_path}/trans
|
||||
|
|
|
@ -12,11 +12,19 @@ final class Env(
|
|||
securityApi: lila.security.SecurityApi,
|
||||
system: ActorSystem,
|
||||
hub: lila.hub.Env,
|
||||
settingStore: lila.memo.SettingStore.Builder,
|
||||
asyncCache: lila.memo.AsyncCache.Builder
|
||||
) {
|
||||
|
||||
private val CollectionReport = config getString "collection.report"
|
||||
private val ActorName = config getString "actor.name"
|
||||
private val ScoreThreshold = config getInt "score.threshold"
|
||||
|
||||
val scoreThresholdSetting = settingStore[Int](
|
||||
"reportScoreThreshold",
|
||||
default = ScoreThreshold,
|
||||
text = "Report score threshold. Reports with lower scores are concealed to moderators".some
|
||||
)
|
||||
|
||||
lazy val forms = new DataForm(hub.actor.captcher)
|
||||
|
||||
|
@ -30,12 +38,13 @@ final class Env(
|
|||
lazy val api = new ReportApi(
|
||||
reportColl,
|
||||
autoAnalysis,
|
||||
discarder = discarder,
|
||||
discarder,
|
||||
noteApi,
|
||||
securityApi,
|
||||
isOnline,
|
||||
asyncCache,
|
||||
system.lilaBus
|
||||
system.lilaBus,
|
||||
scoreThreshold = scoreThresholdSetting.get
|
||||
)
|
||||
|
||||
lazy val modFilters = new ModReportFilter
|
||||
|
@ -73,6 +82,7 @@ object Env {
|
|||
securityApi = lila.security.Env.current.api,
|
||||
system = lila.common.PlayApp.system,
|
||||
hub = lila.hub.Env.current,
|
||||
settingStore = lila.memo.Env.current.settingStore,
|
||||
asyncCache = lila.memo.Env.current.asyncCache
|
||||
)
|
||||
}
|
||||
|
|
|
@ -16,7 +16,8 @@ final class ReportApi(
|
|||
securityApi: lila.security.SecurityApi,
|
||||
isOnline: User.ID => Boolean,
|
||||
asyncCache: lila.memo.AsyncCache.Builder,
|
||||
bus: lila.common.Bus
|
||||
bus: lila.common.Bus,
|
||||
scoreThreshold: () => Int
|
||||
) {
|
||||
|
||||
import lila.db.BSON.BSONJodaDateTimeHandler
|
||||
|
@ -180,13 +181,14 @@ final class ReportApi(
|
|||
private val openSelect: Bdoc = $doc("open" -> true)
|
||||
private val closedSelect: Bdoc = $doc("open" -> false)
|
||||
private val openAvailableSelect: Bdoc = openSelect ++ $doc("inquiry" $exists false)
|
||||
private def scoreThresholdSelect = $doc("score" $gte scoreThreshold())
|
||||
|
||||
private def roomSelect(room: Option[Room]): Bdoc =
|
||||
room.fold($doc("room" $ne Room.Xfiles.key)) { r => $doc("room" -> r) }
|
||||
|
||||
val nbOpenCache = asyncCache.single[Int](
|
||||
name = "report.nbOpen",
|
||||
f = coll.countSel(openSelect ++ roomSelect(none)),
|
||||
f = coll.countSel(openSelect ++ roomSelect(none) ++ scoreThresholdSelect),
|
||||
expireAfter = _.ExpireAfterWrite(1 hour)
|
||||
)
|
||||
|
||||
|
|
Loading…
Reference in New Issue