feat(scoreboard): order by time

This commit is contained in:
2025-11-02 22:50:39 +01:00
parent 2c8f2fed4b
commit 703193513f

View File

@@ -89,6 +89,7 @@ func get_scores(collection: String) -> Array[RTMIScoreRow]:
# Map DB rows to RTMIScoreRow
var scores_untyped = response_data.get("documents").map(func(document): return RTMIScoreRow.new(document))
scores_untyped.sort_custom(func(first, last): return first.time < last.time)
# Array.map() does not support typing, we need to use Array.assign to set the type.
var scores: Array[RTMIScoreRow]
scores.assign(scores_untyped)
@@ -96,13 +97,20 @@ func get_scores(collection: String) -> Array[RTMIScoreRow]:
func submit_score(collection: String, name: String, time: int) -> bool:
var request_data: String = JSON.new().stringify({
"documentId": str(ResourceUID.create_id()),
"data": {
"name": name,
"time": time,
}
})
var request_data: String = (
JSON
. new()
. stringify(
{
"documentId": str(ResourceUID.create_id()),
"data":
{
"name": name,
"time": time,
}
}
)
)
var response_data = await _score_http_request(
http_requests[SUBMIT], "%s/databases/%s/collections/%s/documents" % [url, database_id, collection], HTTPClient.METHOD_POST, request_data
)