show nb open reports

pull/4691/head
Thibault Duplessis 2018-11-02 12:30:09 +01:00
parent 7abce393cd
commit 2b1acbce54
4 changed files with 16 additions and 12 deletions

View File

@ -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

View File

@ -147,7 +147,7 @@ csp: Option[lila.common.ContentSecurityPolicy] = None)(body: Html)(implicit ctx:
</a>
}
@if(isGranted(_.SeeReport)) {
<a class="link text reports" href="@routes.Report.list" data-icon=""><i></i></a>
<a class="link text data-count" href="@routes.Report.list" data-count="@reportNbOpen" data-icon=""></a>
}
<div id="clinput"><a class="link"><span data-icon="y"></span></a><input spellcheck="false" placeholder="@trans.search()"/></div>
<a id="reconnecting" class="link text" data-icon="B">@trans.reconnecting()</a>

View File

@ -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)

View File

@ -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;