Timeout mods now appear on the mod leaderboard
parent
13fdaf0981
commit
071f304c8d
|
@ -323,14 +323,14 @@ final class Mod(
|
|||
}
|
||||
|
||||
def gamify =
|
||||
Secure(_.SeeReport) { implicit ctx => _ =>
|
||||
Secure(_.ChatTimeout) { implicit ctx => _ =>
|
||||
env.mod.gamify.leaderboards zip
|
||||
env.mod.gamify.history(orCompute = true) map { case (leaderboards, history) =>
|
||||
Ok(html.mod.gamify.index(leaderboards, history))
|
||||
}
|
||||
}
|
||||
def gamifyPeriod(periodStr: String) =
|
||||
Secure(_.SeeReport) { implicit ctx => _ =>
|
||||
Secure(_.ChatTimeout) { implicit ctx => _ =>
|
||||
lila.mod.Gamify.Period(periodStr).fold(notFound) { period =>
|
||||
env.mod.gamify.leaderboards map { leaderboards =>
|
||||
Ok(html.mod.gamify.period(leaderboards, period))
|
||||
|
|
|
@ -14,6 +14,7 @@ import lila.user.User
|
|||
final class Gamify(
|
||||
logRepo: ModlogRepo,
|
||||
reportApi: lila.report.ReportApi,
|
||||
modApi: lila.mod.ModApi,
|
||||
cacheApi: lila.memo.CacheApi,
|
||||
historyRepo: HistoryRepo
|
||||
)(implicit ec: scala.concurrent.ExecutionContext) {
|
||||
|
@ -85,22 +86,24 @@ final class Gamify(
|
|||
}
|
||||
|
||||
private def mixedLeaderboard(after: DateTime, before: Option[DateTime]): Fu[List[ModMixed]] =
|
||||
actionLeaderboard(after, before) zip reportLeaderboard(after, before) map { case (actions, reports) =>
|
||||
actions.map(_.modId) intersect reports.map(_.modId) map { modId =>
|
||||
ModMixed(
|
||||
modId,
|
||||
action = actions.find(_.modId == modId) ?? (_.count),
|
||||
report = reports.find(_.modId == modId) ?? (_.count)
|
||||
)
|
||||
} sortBy (-_.score)
|
||||
}
|
||||
for {
|
||||
actions <- actionLeaderboard(after, before)
|
||||
reports <- reportLeaderboard(after, before)
|
||||
modList <- modApi.allMods
|
||||
} yield actions.map(_.modId) intersect modList.map(_.id) diff hidden map { modId =>
|
||||
ModMixed(
|
||||
modId,
|
||||
action = actions.find(_.modId == modId) ?? (_.count),
|
||||
report = reports.find(_.modId == modId) ?? (_.count)
|
||||
)
|
||||
} sortBy (-_.score)
|
||||
|
||||
private def dateRange(from: DateTime, toOption: Option[DateTime]) =
|
||||
$doc("$gte" -> from) ++ toOption.?? { to =>
|
||||
$doc("$lt" -> to)
|
||||
}
|
||||
|
||||
private val notHidden = $nin(User.lichessId, "slanchevbyarg")
|
||||
private val hidden = List(User.lichessId, "irwin")
|
||||
|
||||
private def actionLeaderboard(after: DateTime, before: Option[DateTime]): Fu[List[ModCount]] =
|
||||
logRepo.coll
|
||||
|
@ -109,7 +112,7 @@ final class Gamify(
|
|||
Match(
|
||||
$doc(
|
||||
"date" -> dateRange(after, before),
|
||||
"mod" -> notHidden
|
||||
"mod" -> $nin(hidden)
|
||||
)
|
||||
) -> List(
|
||||
GroupField("mod")("nb" -> SumAll),
|
||||
|
@ -134,7 +137,7 @@ final class Gamify(
|
|||
$doc(
|
||||
"atoms.0.at" -> dateRange(after, before),
|
||||
"room" $in Room.all, // required to make use of the mongodb index room+atoms.0.at
|
||||
"processedBy" -> notHidden
|
||||
"processedBy" -> $nin(hidden)
|
||||
)
|
||||
) -> List(
|
||||
GroupField("processedBy")(
|
||||
|
|
Loading…
Reference in New Issue