more user nb games denormalization, fix filters and improve win chart
This commit is contained in:
parent
5bb6fc273f
commit
de920db74a
|
@ -44,9 +44,9 @@ object GameFilterMenu extends NonEmptyLists {
|
||||||
val all = nel(All, List(
|
val all = nel(All, List(
|
||||||
info.nbWithMe.fold(_ > 0, false) option Me,
|
info.nbWithMe.fold(_ > 0, false) option Me,
|
||||||
(info.nbRated > 0) option Rated,
|
(info.nbRated > 0) option Rated,
|
||||||
(info.nbWin > 0) option Win,
|
(info.user.nbWins > 0) option Win,
|
||||||
(info.nbLoss > 0) option Loss,
|
(info.user.nbLosses > 0) option Loss,
|
||||||
(info.nbDraw > 0) option Draw,
|
(info.user.nbDraws > 0) option Draw,
|
||||||
(info.nbPlaying > 0) option Playing,
|
(info.nbPlaying > 0) option Playing,
|
||||||
(info.nbBookmark > 0) option Bookmark
|
(info.nbBookmark > 0) option Bookmark
|
||||||
).flatten)
|
).flatten)
|
||||||
|
@ -67,9 +67,9 @@ object GameFilterMenu extends NonEmptyLists {
|
||||||
val cachedNb: Option[Int] = current match {
|
val cachedNb: Option[Int] = current match {
|
||||||
case All ⇒ info.user.nbGames.some
|
case All ⇒ info.user.nbGames.some
|
||||||
case Rated ⇒ info.nbRated.some
|
case Rated ⇒ info.nbRated.some
|
||||||
case Win ⇒ info.nbWin.some
|
case Win ⇒ info.user.nbWins.some
|
||||||
case Loss ⇒ info.nbLoss.some
|
case Loss ⇒ info.user.nbLosses.some
|
||||||
case Draw ⇒ info.nbDraw.some
|
case Draw ⇒ info.user.nbDraws.some
|
||||||
case _ ⇒ None
|
case _ ⇒ None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,10 @@ case class User(
|
||||||
nbWins: Int,
|
nbWins: Int,
|
||||||
nbLosses: Int,
|
nbLosses: Int,
|
||||||
nbDraws: Int,
|
nbDraws: Int,
|
||||||
|
nbWinsH: Int, // only against human opponents
|
||||||
|
nbLossesH: Int, // only against human opponents
|
||||||
|
nbDrawsH: Int, // only against human opponents
|
||||||
|
nbAi: Int,
|
||||||
isChatBan: Boolean = false,
|
isChatBan: Boolean = false,
|
||||||
enabled: Boolean,
|
enabled: Boolean,
|
||||||
roles: List[String],
|
roles: List[String],
|
||||||
|
|
|
@ -12,9 +12,6 @@ import scalaz.effects._
|
||||||
case class UserInfo(
|
case class UserInfo(
|
||||||
user: User,
|
user: User,
|
||||||
rank: Option[(Int, Int)],
|
rank: Option[(Int, Int)],
|
||||||
nbWin: Int,
|
|
||||||
nbDraw: Int,
|
|
||||||
nbLoss: Int,
|
|
||||||
nbPlaying: Int,
|
nbPlaying: Int,
|
||||||
nbWithMe: Option[Int],
|
nbWithMe: Option[Int],
|
||||||
nbBookmark: Int,
|
nbBookmark: Int,
|
||||||
|
@ -47,9 +44,6 @@ object UserInfo {
|
||||||
Some(rank -> countUsers())
|
Some(rank -> countUsers())
|
||||||
},
|
},
|
||||||
io(None))
|
io(None))
|
||||||
nbWin = user.nbWins
|
|
||||||
nbLoss = user.nbLosses
|
|
||||||
nbDraw = user.nbDraws
|
|
||||||
nbPlaying ← (ctx is user).fold(
|
nbPlaying ← (ctx is user).fold(
|
||||||
gameRepo count (_ notFinished user) map (_.some),
|
gameRepo count (_ notFinished user) map (_.some),
|
||||||
io(none)
|
io(none)
|
||||||
|
@ -61,7 +55,7 @@ object UserInfo {
|
||||||
nbBookmark = bookmarkApi countByUser user
|
nbBookmark = bookmarkApi countByUser user
|
||||||
eloChart ← eloChartBuilder(user)
|
eloChart ← eloChartBuilder(user)
|
||||||
winChart = (user.nbRatedGames > 0) option {
|
winChart = (user.nbRatedGames > 0) option {
|
||||||
new WinChart(nbWin, nbDraw, nbLoss)
|
new WinChart(user.nbWinsH, user.nbDrawsH, user.nbLossesH, user.nbAi)
|
||||||
}
|
}
|
||||||
eloWithMe = ctx.me.filter(user!=) map { me ⇒
|
eloWithMe = ctx.me.filter(user!=) map { me ⇒
|
||||||
List(
|
List(
|
||||||
|
@ -73,9 +67,6 @@ object UserInfo {
|
||||||
} yield new UserInfo(
|
} yield new UserInfo(
|
||||||
user = user,
|
user = user,
|
||||||
rank = rank,
|
rank = rank,
|
||||||
nbWin = nbWin,
|
|
||||||
nbDraw = nbDraw,
|
|
||||||
nbLoss = nbLoss,
|
|
||||||
nbPlaying = nbPlaying | 0,
|
nbPlaying = nbPlaying | 0,
|
||||||
nbWithMe = nbWithMe,
|
nbWithMe = nbWithMe,
|
||||||
nbBookmark = nbBookmark,
|
nbBookmark = nbBookmark,
|
||||||
|
|
|
@ -8,7 +8,7 @@ import scalaz.effects._
|
||||||
import com.codahale.jerkson.Json
|
import com.codahale.jerkson.Json
|
||||||
import i18n.I18nKeys
|
import i18n.I18nKeys
|
||||||
|
|
||||||
final class WinChart(nbWin: Int, nbDraw: Int, nbLoss: Int) {
|
final class WinChart(nbWin: Int, nbDraw: Int, nbLoss: Int, nbAi: Int) {
|
||||||
|
|
||||||
val columns = Json generate List(
|
val columns = Json generate List(
|
||||||
"string" :: "Result" :: Nil,
|
"string" :: "Result" :: Nil,
|
||||||
|
@ -18,6 +18,7 @@ final class WinChart(nbWin: Int, nbDraw: Int, nbLoss: Int) {
|
||||||
List(
|
List(
|
||||||
List(trans.nbWins.str(nbWin), nbWin),
|
List(trans.nbWins.str(nbWin), nbWin),
|
||||||
List(trans.nbLosses.str(nbLoss), nbLoss),
|
List(trans.nbLosses.str(nbLoss), nbLoss),
|
||||||
List(trans.nbDraws.str(nbDraw), nbDraw))
|
List(trans.nbDraws.str(nbDraw), nbDraw),
|
||||||
|
List("AI", nbAi))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,13 +11,13 @@ case lila.user.GameFilter.Rated => {
|
||||||
@info.nbRated @trans.rated()
|
@info.nbRated @trans.rated()
|
||||||
}
|
}
|
||||||
case lila.user.GameFilter.Win => {
|
case lila.user.GameFilter.Win => {
|
||||||
@trans.nbWins(info.nbWin)
|
@trans.nbWins(info.user.nbWins)
|
||||||
}
|
}
|
||||||
case lila.user.GameFilter.Loss => {
|
case lila.user.GameFilter.Loss => {
|
||||||
@trans.nbLosses(info.nbLoss)
|
@trans.nbLosses(info.user.nbLosses)
|
||||||
}
|
}
|
||||||
case lila.user.GameFilter.Draw => {
|
case lila.user.GameFilter.Draw => {
|
||||||
@trans.nbDraws(info.nbDraw)
|
@trans.nbDraws(info.user.nbDraws)
|
||||||
}
|
}
|
||||||
case lila.user.GameFilter.Playing => {
|
case lila.user.GameFilter.Playing => {
|
||||||
@info.nbPlaying playing
|
@info.nbPlaying playing
|
||||||
|
|
|
@ -1,9 +1,13 @@
|
||||||
db.user2.find({}).forEach(function(user) {
|
db.user2.find({}).forEach(function(user) {
|
||||||
var uid = user['_id'];
|
var uid = user['_id'];
|
||||||
var data = {
|
var data = {
|
||||||
nbWins: db.game2.count({"winId": uid, "players.aiLevel":{$exists:false}}),
|
nbWins: db.game2.count({"winId": uid}),
|
||||||
nbLosses: db.game2.count({"userIds": uid, "status": { "$in": [ 30, 31, 35, 33 ] }, "winId": {"$ne": uid}, "players.aiLevel":{$exists:false}}),
|
nbLosses: db.game2.count({"userIds": uid, "status": { "$in": [ 30, 31, 35, 33 ] }, "winId": {"$ne": uid}}),
|
||||||
nbDraws: db.game2.count({"userIds": uid, "status": { "$in": [34, 32] }, "players.aiLevel":{$exists:false}})
|
nbDraws: db.game2.count({"userIds": uid, "status": { "$in": [34, 32] }}),
|
||||||
|
nbWinsH: db.game2.count({"winId": uid, "players.aiLevel":{$exists:false}}),
|
||||||
|
nbLossesH: db.game2.count({"userIds": uid, "status": { "$in": [ 30, 31, 35, 33 ] }, "winId": {"$ne": uid}, "players.aiLevel":{$exists:false}}),
|
||||||
|
nbDrawsH: db.game2.count({"userIds": uid, "status": { "$in": [34, 32] }, "players.aiLevel":{$exists:false}}),
|
||||||
|
nbAi: db.game2.count({"userIds": uid, "players.aiLevel":{$exists:true}})
|
||||||
};
|
};
|
||||||
db.user2.update({"_id": uid}, {"$set":data});
|
db.user2.update({"_id": uid}, {"$set":data});
|
||||||
});
|
});
|
||||||
|
|
2
todo
2
todo
|
@ -43,4 +43,4 @@ count ai games in nb wins/losses http://en.lichess.org/@/ivym http://en.lichess.
|
||||||
index game positions
|
index game positions
|
||||||
integrate with google+
|
integrate with google+
|
||||||
elo stats
|
elo stats
|
||||||
feedback changes to do http://en.lichess.org/forum/lichess-feedback/new-feature-landing-advanced-search#3
|
player search autocomplete regex escapement
|
||||||
|
|
Loading…
Reference in a new issue