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(
DBObject("_id" -> username.toLowerCase)
).map(history
(history.as[MongoDBList]("entries").toList collect {
case elem: com.mongodb.BasicDBList for {
ts elem.getAs[Double](0)
elo elem.getAs[Double](1)
op = if (elem.size > 2) elem.getAs[Double](2) else None
} yield (ts.toInt, elo.toInt, op map (_.toInt))
}).flatten sortBy (_._1)
(history.as[MongoDBList]("entries").toList collect {
case elem: com.mongodb.BasicDBList try {
for {
ts elem.getAs[Double](0)
elo elem.getAs[Double](1)
op = if (elem.size > 2) elem.getAs[Double](2) else None
} 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 }
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 regex = "^" + escaped + ".*$"
collection.find(
DBObject("_id" -> regex.r),
DBObject("username" -> 1))
.sort(DBObject("_id" -> 1))
.limit(10)
.limit(max)
.toList
.map(_.getAs[String]("username"))
.flatten

1
todo
View file

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