elo chart debugging

This commit is contained in:
Thibault Duplessis 2012-12-31 16:45:33 +01:00
parent ad9316d889
commit 0d7a8a35a3
3 changed files with 19 additions and 10 deletions

View file

@ -26,13 +26,21 @@ final class HistoryRepo(collection: MongoCollection) {
~collection.findOne( ~collection.findOne(
DBObject("_id" -> username.toLowerCase) DBObject("_id" -> username.toLowerCase)
).map(history ).map(history
(history.as[MongoDBList]("entries").toList collect { (history.as[MongoDBList]("entries").toList collect {
case elem: com.mongodb.BasicDBList for { case elem: com.mongodb.BasicDBList try {
ts elem.getAs[Double](0) for {
elo elem.getAs[Double](1) ts elem.getAs[Double](0)
op = if (elem.size > 2) elem.getAs[Double](2) else None elo elem.getAs[Double](1)
} yield (ts.toInt, elo.toInt, op map (_.toInt)) op = if (elem.size > 2) elem.getAs[Double](2) else None
}).flatten sortBy (_._1) } yield (ts.toInt, elo.toInt, op map (_.toInt))
}
catch {
case (err: Exception) {
println("ERR while parsing %s history: %s(%s)".format(username, err.getClass, err.getMessage))
none
}
}
}).flatten sortBy (_._1)
) )
} except { err putStrLn("ERR while parsing user history: " + err.getMessage) inject Nil } }
} }

View file

@ -167,14 +167,14 @@ class UserRepo(collection: MongoCollection)
val countEnabled: IO[Int] = io { count(enabledQuery).toInt } val countEnabled: IO[Int] = io { count(enabledQuery).toInt }
def usernamesLike(username: String): IO[List[String]] = io { def usernamesLike(username: String, max: Int = 10): IO[List[String]] = io {
val escaped = """^([\w-]*).*$""".r.replaceAllIn(normalize(username), _ group 1) val escaped = """^([\w-]*).*$""".r.replaceAllIn(normalize(username), _ group 1)
val regex = "^" + escaped + ".*$" val regex = "^" + escaped + ".*$"
collection.find( collection.find(
DBObject("_id" -> regex.r), DBObject("_id" -> regex.r),
DBObject("username" -> 1)) DBObject("username" -> 1))
.sort(DBObject("_id" -> 1)) .sort(DBObject("_id" -> 1))
.limit(10) .limit(max)
.toList .toList
.map(_.getAs[String]("username")) .map(_.getAs[String]("username"))
.flatten .flatten

1
todo
View file

@ -56,3 +56,4 @@ traduction intégrale
block user creation from an IP block user creation from an IP
mute IP mute IP
add elo filter to the lobby add elo filter to the lobby
elo chart bug http://en.lichess.org/@/amir8869154