From 2b1acbce542556fd4b5c4784bf9253bf63083c5c Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Fri, 2 Nov 2018 12:30:09 +0100 Subject: [PATCH] show nb open reports --- app/templating/Environment.scala | 3 +++ app/views/base/layout.scala.html | 2 +- modules/report/src/main/ReportApi.scala | 15 ++++++++++++--- public/stylesheets/common.css | 8 -------- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/templating/Environment.scala b/app/templating/Environment.scala index b6d2cab3a6..a6e593edd6 100644 --- a/app/templating/Environment.scala +++ b/app/templating/Environment.scala @@ -59,6 +59,9 @@ object Environment def isChatPanicEnabled = lila.chat.Env.current.panic.enabled + def reportNbOpen: Int = + lila.report.Env.current.api.nbOpen.awaitOrElse(10.millis, 0) + def NotForKids[Html](f: => Html)(implicit ctx: lila.api.Context) = if (ctx.kid) emptyHtml else f diff --git a/app/views/base/layout.scala.html b/app/views/base/layout.scala.html index 841c13ab18..dfc041c567 100644 --- a/app/views/base/layout.scala.html +++ b/app/views/base/layout.scala.html @@ -147,7 +147,7 @@ csp: Option[lila.common.ContentSecurityPolicy] = None)(body: Html)(implicit ctx: } @if(isGranted(_.SeeReport)) { - + }
@trans.reconnecting() diff --git a/modules/report/src/main/ReportApi.scala b/modules/report/src/main/ReportApi.scala index 9fbe1a7021..bfa1c3e7f9 100644 --- a/modules/report/src/main/ReportApi.scala +++ b/modules/report/src/main/ReportApi.scala @@ -39,10 +39,12 @@ final class ReportApi( } } - private def monitorOpen = - coll.countSel(selectOpenAvailableInRoom(none)) foreach { - lila.mon.mod.report.unprocessed(_) + private def monitorOpen = { + nbOpenCache.refresh + nbOpen foreach { nb => + lila.mon.mod.report.unprocessed(nb) } + } private def isAlreadySlain(candidate: Report.Candidate) = (candidate.isCheat && candidate.suspect.user.engine) || @@ -181,6 +183,13 @@ final class ReportApi( private def selectOpenAvailableInRoom(room: Option[Room]) = $doc("open" -> true, "inquiry" $exists false) ++ roomSelect(room) ++ scoreThresholdSelect + val nbOpenCache = asyncCache.single[Int]( + name = "report.nbOpen", + f = coll.countSel(selectOpenAvailableInRoom(none)), + expireAfter = _.ExpireAfterWrite(1 hour) + ) + def nbOpen = nbOpenCache.get + def recent(suspect: Suspect, nb: Int, readPreference: ReadPreference = ReadPreference.secondaryPreferred): Fu[List[Report]] = coll.find($doc("user" -> suspect.id.value)).sort(sortLastAtomAt).list[Report](nb, readPreference) diff --git a/public/stylesheets/common.css b/public/stylesheets/common.css index 3e393d408d..42816f91ab 100644 --- a/public/stylesheets/common.css +++ b/public/stylesheets/common.css @@ -498,14 +498,6 @@ body > div.content { #top > * { position: relative; } -#top .reports i { - border-radius: 50%; - position: absolute; - right: 5px; - width: 12px; - height: 12px; - background-image: linear-gradient(#d85000, #b34100); -} #top .dropdown { display: none; position: absolute;