From 28685aeb1541fd92125437c8544c79feefa0f21c Mon Sep 17 00:00:00 2001 From: Thibault Duplessis Date: Sun, 24 Jan 2016 11:07:42 +0700 Subject: [PATCH] optimize crosstable --- modules/game/src/main/CrosstableApi.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/game/src/main/CrosstableApi.scala b/modules/game/src/main/CrosstableApi.scala index 465b6eddc0..fc5508232a 100644 --- a/modules/game/src/main/CrosstableApi.scala +++ b/modules/game/src/main/CrosstableApi.scala @@ -77,11 +77,11 @@ final class CrosstableApi(coll: Coll) { BSONDocument(Game.BSONFields.winnerId -> true) ).sort(BSONDocument(Game.BSONFields.createdAt -> -1)) .cursor[BSONDocument]().collect[List](maxGames).map { - _.map { doc => + _.flatMap { doc => doc.getAs[String](Game.BSONFields.id).map { id => Result(id, doc.getAs[String](Game.BSONFields.winnerId)) } - }.flatten.reverse + }.reverse } nbGames <- gameColl.count(selector.some) ctDraft = Crosstable(Crosstable.User(su1, 0), Crosstable.User(su2, 0), localResults, nbGames)