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