forget about notes in the report list view
parent
b2fdd2fc4b
commit
8f79b25a50
|
@ -27,7 +27,7 @@ object Report extends LilaController {
|
|||
api.openAndRecentWithFilter(20, Room(room)) zip
|
||||
api.countOpenByRooms flatMap {
|
||||
case reports ~ counts =>
|
||||
(Env.user.lightUserApi preloadMany reports.flatMap(_.userIds)) inject
|
||||
(Env.user.lightUserApi preloadMany reports.flatMap(_.report.userIds)) inject
|
||||
Ok(html.report.list(reports, room, counts))
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
@(reports: List[lila.report.Report.WithSuspectAndNotes], filter: String, counts: lila.report.Room.Counts)(implicit ctx: Context)
|
||||
@(reports: List[lila.report.Report.WithSuspect], filter: String, counts: lila.report.Room.Counts)(implicit ctx: Context)
|
||||
|
||||
@import lila.report.Report.{WithSuspect,WithSuspectAndNotes}
|
||||
@import lila.report.Report.WithSuspect
|
||||
|
||||
@title = @{ "Reports" }
|
||||
|
||||
@tab(reports: List[WithSuspectAndNotes], room: lila.report.Room) = {
|
||||
@tab(reports: List[WithSuspect], room: lila.report.Room) = {
|
||||
<a href="@routes.Report.listWithFilter(room.key)"
|
||||
class="@when(counts.value.contains(room), "new") @filter.active(room.key)">
|
||||
<count>@counts.get(room)</count>@room.name</a>
|
||||
|
@ -37,7 +37,7 @@ moreCss = cssTag("report.css")) {
|
|||
</thead>
|
||||
<tbody>
|
||||
@reports.map {
|
||||
case WithSuspectAndNotes(WithSuspect(r, sus, _), notes) if (!r.isTrollOrInsult || isGranted(_.MarkTroll)) => {
|
||||
case WithSuspect(r, sus, _) if (!r.isTrollOrInsult || isGranted(_.MarkTroll)) => {
|
||||
<tr class="@r.open.fold("new", "")">
|
||||
<td>
|
||||
@reportScore(r.score)
|
||||
|
@ -45,12 +45,6 @@ moreCss = cssTag("report.css")) {
|
|||
@userLink(sus.user, params = "?mod")<br />
|
||||
<p class="perfs">@showBestPerfs(sus.user, 2)</p>
|
||||
@user.userMarks(sus.user, none)
|
||||
@if(notes.nonEmpty) {
|
||||
<br />
|
||||
<a href="@routes.User.show(sus.user.username)?notes=1">
|
||||
<strong>@pluralize("note", notes.size) by @notes.map(_.from).map(usernameOrId).mkString(", ")</strong>
|
||||
</a>
|
||||
}
|
||||
</td>
|
||||
<td class="atoms">
|
||||
@r.bestAtoms(3).map { atom =>
|
||||
|
|
|
@ -106,15 +106,6 @@ object Report {
|
|||
(report.closed ?? Int.MinValue)
|
||||
}
|
||||
|
||||
case class WithSuspectAndNotes(withSuspect: WithSuspect, notes: List[Note]) {
|
||||
def report = withSuspect.report
|
||||
def suspect = withSuspect.suspect
|
||||
def hasLichessNote = notes.exists(_.from == lichessId)
|
||||
def hasIrwinNote = notes.exists(_.from == "irwin")
|
||||
|
||||
def userIds = report.userIds ::: notes.flatMap(_.userIds)
|
||||
}
|
||||
|
||||
case class ByAndAbout(by: List[Report], about: List[Report]) {
|
||||
def userIds = by.flatMap(_.userIds) ::: about.flatMap(_.userIds)
|
||||
}
|
||||
|
|
|
@ -181,7 +181,7 @@ final class ReportApi(
|
|||
|
||||
val nbOpenCache = asyncCache.single[Int](
|
||||
name = "report.nbOpen",
|
||||
f = coll.countSel(openSelect ++ roomSelect(none) ++ scoreThresholdSelect),
|
||||
f = coll.countSel(openAvailableSelect ++ roomSelect(none) ++ scoreThresholdSelect),
|
||||
expireAfter = _.ExpireAfterWrite(1 hour)
|
||||
)
|
||||
|
||||
|
@ -210,7 +210,7 @@ final class ReportApi(
|
|||
ReadPreference.secondaryPreferred
|
||||
) map (_ filterNot UserRepo.lichessId.==)
|
||||
|
||||
def openAndRecentWithFilter(nb: Int, room: Option[Room]): Fu[List[Report.WithSuspectAndNotes]] = for {
|
||||
def openAndRecentWithFilter(nb: Int, room: Option[Room]): Fu[List[Report.WithSuspect]] = for {
|
||||
opens <- findBest(nb, openAvailableSelect ++ roomSelect(room) ++ scoreThresholdSelect)
|
||||
nbClosed = nb - opens.size
|
||||
closed <- if (room.has(Room.Xfiles) || nbClosed < 1) fuccess(Nil)
|
||||
|
@ -221,19 +221,14 @@ final class ReportApi(
|
|||
def next(room: Room): Fu[Option[Report]] =
|
||||
findBest(1, openAvailableSelect ++ roomSelect(room.some) ++ scoreThresholdSelect).map(_.headOption)
|
||||
|
||||
private def addSuspectsAndNotes(reports: List[Report]): Fu[List[Report.WithSuspectAndNotes]] = for {
|
||||
users <- UserRepo byIdsSecondary (reports.map(_.user).distinct :+ "neio")
|
||||
withSuspects = reports.flatMap { r =>
|
||||
users.find(_.id == r.user).orElse(users.find(_.id == "neio")) map { u =>
|
||||
Report.WithSuspect(r, Suspect(u), isOnline(u.id))
|
||||
}
|
||||
}.sortBy(-_.urgency)
|
||||
withNotes <- noteApi.byMod(withSuspects.map(_.suspect.user.id).distinct) map { notes =>
|
||||
withSuspects.map { wu =>
|
||||
Report.WithSuspectAndNotes(wu, notes.filter(_.to == wu.suspect.user.id))
|
||||
}
|
||||
private def addSuspectsAndNotes(reports: List[Report]): Fu[List[Report.WithSuspect]] =
|
||||
UserRepo byIdsSecondary (reports.map(_.user).distinct :+ "neio") map { users =>
|
||||
reports.flatMap { r =>
|
||||
users.find(_.id == r.user).orElse(users.find(_.id == "neio")) map { u =>
|
||||
Report.WithSuspect(r, Suspect(u), isOnline(u.id))
|
||||
}
|
||||
}.sortBy(-_.urgency)
|
||||
}
|
||||
} yield withNotes
|
||||
|
||||
private[report] def resetScores: Funit = scorer reset coll void
|
||||
|
||||
|
@ -277,7 +272,7 @@ final class ReportApi(
|
|||
def countOpenByRooms: Fu[Room.Counts] = {
|
||||
import reactivemongo.api.collections.bson.BSONBatchCommands.AggregationFramework._
|
||||
coll.aggregate(
|
||||
Match(openSelect ++ scoreThresholdSelect ++ roomSelect(none)),
|
||||
Match(openAvailableSelect ++ scoreThresholdSelect ++ roomSelect(none)),
|
||||
List(
|
||||
GroupField("room")("nb" -> SumValue(1))
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue