show other users notes in mod view - closes #3332

pull/3300/head^2
Thibault Duplessis 2017-07-23 14:57:01 +02:00
parent 9a8eed967c
commit 0a82d9c34d
4 changed files with 14 additions and 7 deletions

View File

@ -248,14 +248,14 @@ object User extends LilaController {
Env.plan.api.recentChargesOf(user) zip
Env.report.api.byAndAbout(user, 20) zip
Env.pref.api.getPref(user) zip
Env.irwin.api.status(user) zip
Env.user.noteApi.forMod(user.id) flatMap {
case emails ~ spy ~ assess ~ history ~ charges ~ reports ~ pref ~ irwin ~ notes =>
Env.irwin.api.status(user) flatMap {
case emails ~ spy ~ assess ~ history ~ charges ~ reports ~ pref ~ irwin =>
(Env.playban.api bans spy.usersSharingIp.map(_.id)) zip
Env.user.noteApi.forMod(user.id :: spy.otherUserIds) zip
Env.user.lightUserApi.preloadMany {
reports.userIds ::: assess.??(_.games).flatMap(_.userIds)
} map {
case (bans, _) =>
case bans ~ notes ~ _ =>
html.user.mod(user, emails, spy, assess, bans, history, charges, reports, pref, irwin, notes)
}
}

View File

@ -273,9 +273,9 @@
</td>
<td data-sort="@o.count.game">@o.count.game.localize</td>
<td class="i">
@defining(notes.filter(_.to == o.id)) { notes =>
@if(notes.nonEmpty) {
<a href="@routes.User.show(o.username)?notes"><i title="Notes from @notes.map(_.from).map(usernameOrId).mkString(", ")" data-icon="m" class="is-green"></i>@notes.size</a>
@defining(notes.filter(_.to == o.id)) { ns =>
@if(ns.nonEmpty) {
<a href="@routes.User.show(o.username)?notes"><i title="Notes from @ns.map(_.from).map(usernameOrId).mkString(", ")" data-icon="m" class="is-green"></i>@ns.size</a>
}
}
@bans.get(o.id).map { nb => <i title="Playban" data-icon="p"></i>@nb }

View File

@ -27,6 +27,8 @@ case class UserSpy(
OtherUser(_, false, true)
}
}.sortBy(-_.user.createdAt.getMillis)
def otherUserIds = otherUsers.map(_.user.id)
}
object UserSpy {

View File

@ -49,6 +49,11 @@ final class NoteApi(
.sort($doc("date" -> -1))
.list[Note](20)
def forMod(ids: List[User.ID]): Fu[List[Note]] =
coll.find($doc("to" -> $doc("$in" -> ids)))
.sort($doc("date" -> -1))
.list[Note](50)
def byMod(ids: List[User.ID]): Fu[List[Note]] =
coll.find($doc("to" $in ids))
.sort($doc("date" -> -1))