elo chart debugging
This commit is contained in:
parent
ad9316d889
commit
0d7a8a35a3
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue