show nb blockers to mods

This commit is contained in:
Thibault Duplessis 2013-09-15 10:50:43 +02:00
parent 3d3bb3b142
commit 6b122b9e10
3 changed files with 12 additions and 1 deletions

View file

@ -2,10 +2,12 @@ package lila.app
package mashup
import chess.{ EloCalculator, Color }
import lila.bookmark.BookmarkApi
import lila.forum.PostApi
import lila.game.{ GameRepo, Game }
import lila.relation.RelationApi
import lila.security.Granter
import lila.user.{ User, UserRepo, Context, EloChart, Confrontation }
case class UserInfo(
@ -17,6 +19,7 @@ case class UserInfo(
eloChart: Option[EloChart],
nbFollowing: Int,
nbFollowers: Int,
nbBlockers: Option[Int],
nbPosts: Int) {
def nbRated = user.count.rated
@ -48,8 +51,11 @@ object UserInfo {
EloChart(user) zip
relationApi.nbFollowing(user.id) zip
relationApi.nbFollowers(user.id) zip
((ctx.me ?? Granter(_.UserSpy)) ?? {
relationApi.nbBlockers(user.id) map (_.some)
}) zip
postApi.nbByUser(user.id) map {
case (((((((rank, nbPlaying), confrontation), nbBookmark), eloChart), nbFollowing), nbFollowers), nbPosts) new UserInfo(
case ((((((((rank, nbPlaying), confrontation), nbBookmark), eloChart), nbFollowing), nbFollowers), nbBlockers), nbPosts) new UserInfo(
user = user,
rank = rank,
nbPlaying = ~nbPlaying,
@ -58,6 +64,7 @@ object UserInfo {
eloChart = eloChart,
nbFollowing = nbFollowing,
nbFollowers = nbFollowers,
nbBlockers = nbBlockers,
nbPosts = nbPosts)
}
}

View file

@ -85,6 +85,9 @@ evenMoreCss = evenMoreCss) {
<div class="social content_box_inter">
<a class="intertab" href="@routes.Relation.following(u.username)">@splitNumber(trans.nbFollowing(info.nbFollowing))</a>
<a class="intertab" href="@routes.Relation.followers(u.username)">@splitNumber(trans.nbFollowers(info.nbFollowers))</a>
@info.nbBlockers.map { nb =>
<a class="intertab">@splitNumber(nb + " Blockers")</a>
}
<span class="intertab">@splitNumber(u.toints + " " + trans.tournamentPoints())</span>
<a class="intertab" href="@routes.ForumPost.search("user:" + u.username, 1)">@splitNumber(info.nbPosts + " Forum posts")</a>
<div class="relation_actions">

View file

@ -23,6 +23,7 @@ final class RelationApi(
def nbFollowers(userId: ID) = followers(userId) map (_.size)
def nbFollowing(userId: ID) = following(userId) map (_.size)
def nbBlockers(userId: ID) = blockers(userId) map (_.size)
def friends(userId: ID) = cached friends userId
def areFriends(u1: ID, u2: ID) = friends(u1) map (_ contains u2)