Skip to main content
Version: 5.9.6

GetRankListByScore

BackendReturnObject GetRankListByScore(string rankUuid, int score); BackendReturnObject GetRankListByScore(string rankUuid, long score);

Note
Old version rankings cannot use this method.

Parameters

ValueTypeDescription
rankUuidstringuuid of the ranking to look up
scoreint/longScore to look up

The rankUuid value can be checked using the following methods:

Description

Among the rank holders registered in the ranking, looks up the rank holder with the score value and rank holders above and below that score using a uuid value.

  • If there are multiple users with the looked-up score, all of them will be looked up.
  • Even if there are multiple users above and below the score, only one user above and below will be looked up.

Example

Synchronous

var score = 0; //Score to look up
Backend.URank.User.GetRankListByScore("rankUuid", score);

Asynchronous

var score = 0; //Score to look up
Backend.URank.User.GetRankListByScore("rankUuid", score, callback=> {
// Post-process
});

SendQueue

var score = 0; //Score to look up
SendQueue.Enqueue(Backend.URank.User.GetRankListByScore, "rankUuid", score, callback => {
// Post-process
});

Return cases

Success cases

When the lookup is successful
statusCode : 200

returnValue : refer to GetReturnValuetoJSON

When the lookup is successful but the user of the ranking is not registered
statusCode : 200

returnValue : {"rows":[],"previousRank":{"NULL":true},"nextRank":{"NULL":true},"totalCount":0}

When the lookup is successful but there is no user with that score
statusCode : 200

returnValue : refer to GetReturnValuetoJSON

Error cases

When the uuid is null or string.Empty
statusCode : 400
errorCode : ValidationException

When there is an attempt to look up with a non-existent uuid
statusCode : 404
errorCode : NotFoundException

GetReturnValuetoJSON

When the user with the score and users above and below that score all exist

{
"rows": [
{
// User inDate
"gamerInDate": {
"S": "2021-03-10T06:01:05.098Z"
},
// User nickname
"nickname": {
"S": "Nickname No. 0"
},
// Additional field
// Name and value of the column are displayed.
// 'CONNECTION_MIN' if the column name of the additional field is 'CONNECTION_MIN'
"CONNECTION_MIN": {
"S": "6P0LIECBQIEV"
},
// Score
// Column names are unified as 'score'.
// It will be called 'score' even if the column name of the ranking field is 'power.'
"score": {
"N": 100
},
// offset
"index": {
"N": 10
},
// User's rank
"rank": {
"N": 9
}
},
// and etc...
],
// When the previousRank does not exist
"previousRank": {
"NULL": true
},
// When the previousRank exists
// Only 1 user is looked up.
"previousRank": [
{
"gamerInDate": {
"S": "2021-03-10T06:02:36.416Z"
},
"nickname": {
"S": "Nickname No. 10"
},
"CONNECTION_MIN": {
"S": "SS3P9KH58U92"
},
"score": {
"N": 101
},
"index": {
"N": 9
},
"rank": {
"N": 8
}
}
],
// When the nextRank does not exist
"nextRank": {
"NULL": true
},
// When the nextRank exists
// Only 1 user is looked up.
"nextRank": [
{
"gamerInDate": {
"S": "2021-03-10T06:02:36.415Z"
},
"nickname": {
"S": "Nickname No. 100"
},
"CONNECTION_MIN": {
"S": "SS3P9KH58T33"
},
"score": {
"N": "99"
},
"index": {
"N": 11
},
"rank": {
"N": 10
}
}
],
// Total number of rank holders in the ranking
"totalCount": 907
}

When there are no users with the score but there is a user with a higher score

{
"rows": [ ],
// When the previousRank exists
// Only 1 user is looked up.
"previousRank": [
{
"gamerInDate": {
"S": "2021-03-10T06:02:36.416Z"
},
"nickname": {
"S": "Nickname No. 10"
},
"CONNECTION_MIN": {
"S": "SS3P9KH58U92"
},
"score": {
"N": 101
},
"index": {
"N": 9
},
"rank": {
"N": 8
}
}
],
// When the nextRank does not exist
"nextRank": {
"NULL": true
},
// Total number of rank holders in the ranking
"totalCount": 907
}

Sample code

public class RankItem
{
public string gamerInDate;
public string nickname;
public string score;
public string index;
public string rank;
public string extraData = string.Empty;
public string extraName = string.Empty;
public string totalCount;

public override string ToString()
{
string str = $"UserinDate:{gamerInDate}\nNikckname:{nickname}\nScore:{score}\nSort:{index}\nPlacement:{rank}\nTotal:{totalCount}\n";
if(extraName != string.Empty)
{
str += $"{extraName}:{extraData}\n";
}
return str;
}
}
public void GetRankListByScoreTest()
{
string userUuid = "81272320-8c40-112b-b174-d9233f6bd0e8";
int score = 1835242435;

List<RankItem> rankItemList = new List<RankItem>();

BackendReturnObject bro = Backend.URank.User.GetRankListByScore(userUuid, score);

if(bro.IsSuccess())
{
LitJson.JsonData rankListJson = bro.GetFlattenJSON();

for(int i = 0; i < rankListJson["previousRank"].Count; i++)
{
RankItem rankItem = new RankItem();

rankItem.gamerInDate = rankListJson["previousRank"][i]["gamerInDate"].ToString();
rankItem.nickname = rankListJson["previousRank"][i]["nickname"].ToString();
rankItem.score = rankListJson["previousRank"][i]["score"].ToString();
rankItem.index = rankListJson["previousRank"][i]["index"].ToString();
rankItem.rank = rankListJson["previousRank"][i]["rank"].ToString();
rankItem.totalCount = rankListJson["totalCount"].ToString();

if(rankListJson["previousRank"][i].ContainsKey(rankItem.extraName))
{
rankItem.extraData = rankListJson["previousRank"][i][rankItem.extraName].ToString();
}

rankItemList.Add(rankItem);
Debug.Log(rankItem.ToString());
}

for(int i = 0; i < rankListJson["rows"].Count; i++)
{
RankItem rankItem = new RankItem();

rankItem.gamerInDate = rankListJson["rows"][i]["gamerInDate"].ToString();
rankItem.nickname = rankListJson["rows"][i]["nickname"].ToString();
rankItem.score = rankListJson["rows"][i]["score"].ToString();
rankItem.index = rankListJson["rows"][i]["index"].ToString();
rankItem.rank = rankListJson["rows"][i]["rank"].ToString();
rankItem.totalCount = rankListJson["totalCount"].ToString();

if(rankListJson["rows"][i].ContainsKey(rankItem.extraName))
{
rankItem.extraData = rankListJson["rows"][i][rankItem.extraName].ToString();
}

rankItemList.Add(rankItem);
Debug.Log(rankItem.ToString());
}

for(int i = 0; i < rankListJson["nextRank"].Count; i++)
{
RankItem rankItem = new RankItem();

rankItem.gamerInDate = rankListJson["nextRank"][i]["gamerInDate"].ToString();
rankItem.nickname = rankListJson["nextRank"][i]["nickname"].ToString();
rankItem.score = rankListJson["nextRank"][i]["score"].ToString();
rankItem.index = rankListJson["nextRank"][i]["index"].ToString();
rankItem.rank = rankListJson["nextRank"][i]["rank"].ToString();
rankItem.totalCount = rankListJson["totalCount"].ToString();

if(rankListJson["nextRank"][i].ContainsKey(rankItem.extraName))
{
rankItem.extraData = rankListJson["nextRank"][i][rankItem.extraName].ToString();
}

rankItemList.Add(rankItem);
Debug.Log(rankItem.ToString());
}
}
}