preload report users
This commit is contained in:
parent
1b85c61dce
commit
6f2d947a37
|
@ -21,12 +21,11 @@ object Report extends LilaController {
|
|||
renderList(reason)
|
||||
}
|
||||
|
||||
private def renderList(reason: String)(implicit ctx: Context) =
|
||||
api.unprocessedAndRecentWithFilter(50, Reason(reason)) flatMap { reports =>
|
||||
api.countUnprocesssedByReasons map { counts =>
|
||||
Ok(html.report.list(reports, reason, counts))
|
||||
}
|
||||
}
|
||||
private def renderList(reason: String)(implicit ctx: Context) = for {
|
||||
reports <- api.unprocessedAndRecentWithFilter(50, Reason(reason))
|
||||
counts <- api.countUnprocesssedByReasons
|
||||
_ <- Env.user.lightUserApi preloadMany reports.flatMap(_.userIds)
|
||||
} yield Ok(html.report.list(reports, reason, counts))
|
||||
|
||||
def process(id: String) = Secure(_.SeeReport) { implicit ctx => me =>
|
||||
api.process(id, me) inject Redirect(routes.Report.list)
|
||||
|
|
|
@ -41,6 +41,8 @@ case class Report(
|
|||
def unprocessed = processedBy.isEmpty
|
||||
def processed = processedBy.isDefined
|
||||
|
||||
def userIds = List(user, createdBy)
|
||||
|
||||
lazy val realReason: Reason = Reason byKey reason
|
||||
}
|
||||
|
||||
|
@ -59,6 +61,8 @@ object Report {
|
|||
def user = withUser.user
|
||||
def hasLichessNote = notes.exists(_.from == "lichess")
|
||||
def hasIrwinNote = notes.exists(_.from == "irwin")
|
||||
|
||||
def userIds = report.userIds ::: notes.flatMap(_.userIds)
|
||||
}
|
||||
|
||||
case class ByAndAbout(by: List[Report], about: List[Report])
|
||||
|
|
|
@ -5,13 +5,15 @@ import org.joda.time.DateTime
|
|||
import reactivemongo.api.ReadPreference
|
||||
|
||||
case class Note(
|
||||
_id: String,
|
||||
from: String,
|
||||
to: String,
|
||||
text: String,
|
||||
troll: Boolean,
|
||||
mod: Boolean,
|
||||
date: DateTime)
|
||||
_id: String,
|
||||
from: String,
|
||||
to: String,
|
||||
text: String,
|
||||
troll: Boolean,
|
||||
mod: Boolean,
|
||||
date: DateTime) {
|
||||
def userIds = List(from, to)
|
||||
}
|
||||
|
||||
case class UserNotes(user: User, notes: List[Note])
|
||||
|
||||
|
|
Loading…
Reference in a new issue