diff --git a/app/mashup/UserInfo.scala b/app/mashup/UserInfo.scala index b9eafaa849..6b8af6c953 100644 --- a/app/mashup/UserInfo.scala +++ b/app/mashup/UserInfo.scala @@ -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) } } diff --git a/app/views/user/show.scala.html b/app/views/user/show.scala.html index 258e29017a..936c7329e3 100644 --- a/app/views/user/show.scala.html +++ b/app/views/user/show.scala.html @@ -85,6 +85,9 @@ evenMoreCss = evenMoreCss) {
@splitNumber(trans.nbFollowing(info.nbFollowing)) @splitNumber(trans.nbFollowers(info.nbFollowers)) + @info.nbBlockers.map { nb => + @splitNumber(nb + " Blockers") + } @splitNumber(u.toints + " " + trans.tournamentPoints()) @splitNumber(info.nbPosts + " Forum posts")
diff --git a/modules/relation/src/main/RelationApi.scala b/modules/relation/src/main/RelationApi.scala index 9c45994086..90cb32c0c5 100644 --- a/modules/relation/src/main/RelationApi.scala +++ b/modules/relation/src/main/RelationApi.scala @@ -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)