|
@@ -31,6 +31,7 @@ class Mongo : Connector {
|
|
|
val query = Document().append("name", name)
|
|
val query = Document().append("name", name)
|
|
|
val updates = Updates.combine(
|
|
val updates = Updates.combine(
|
|
|
Updates.set("score", score),
|
|
Updates.set("score", score),
|
|
|
|
|
+ Updates.set("rank", rank),
|
|
|
Updates.currentTimestamp("lastUpdated")
|
|
Updates.currentTimestamp("lastUpdated")
|
|
|
)
|
|
)
|
|
|
val options = UpdateOptions().upsert(true)
|
|
val options = UpdateOptions().upsert(true)
|
|
@@ -52,7 +53,6 @@ class Mongo : Connector {
|
|
|
}
|
|
}
|
|
|
override fun listAll(): List<Player> {
|
|
override fun listAll(): List<Player> {
|
|
|
try {
|
|
try {
|
|
|
-
|
|
|
|
|
val projectionFields = Projections.fields(
|
|
val projectionFields = Projections.fields(
|
|
|
Projections.include("name", "score", "rank"),
|
|
Projections.include("name", "score", "rank"),
|
|
|
Projections.excludeId()
|
|
Projections.excludeId()
|
|
@@ -62,7 +62,7 @@ class Mongo : Connector {
|
|
|
.sort(Sorts.descending("score"))
|
|
.sort(Sorts.descending("score"))
|
|
|
val players = mutableListOf<Player>()
|
|
val players = mutableListOf<Player>()
|
|
|
doc.forEach { it: Document ->
|
|
doc.forEach { it: Document ->
|
|
|
- players.add(Player(it.getString("name"), it.getInteger("score"), it.getInteger("rank")))
|
|
|
|
|
|
|
+ players.add(Player(it.getString("name"), it.getInteger("score"), it.getInteger("rank")?: 0))
|
|
|
}
|
|
}
|
|
|
return players
|
|
return players
|
|
|
} catch (me: MongoException) {
|
|
} catch (me: MongoException) {
|