Skip to main content
Version: 5.9.6

GetRankTableList

public BackendReturnObject GetRankTableList();

Note
Old version rankings cannot use this method.

Description

Returns all user rankings generated in BACKND Console as a list.
The list contains the following information:

  • Ranking name
  • Ranking uuid
  • Ranking cycle
  • Whether to initialize data when initializing the ranking
  • How to sort ranking
  • Table used in the ranking
  • Column used in the ranking
  • Additional fields used in the ranking

Example

Synchronous

Backend.URank.User.GetRankTableList();

Asynchronous

Backend.URank.User.GetRankTableList(callback=>
{
// Post-process
});

SendQueue

SendQueue.Enqueue(Backend.URank.User.GetRankTableList, callback => 
{
// Post-process
});

Return cases

Success cases

When the lookup is successful
statusCode : 200

returnValue : refer to GetReturnValuetoJSON

Error cases

When the ranking does not exist
statusCode : 404
errorCode : NotFoundException

GetReturnValuetoJSON

{
"rows": [
{
// Rank type. 'user' in case of user ranking
"rankType": {
"S": "user"
},
// Exists only for one-time rankings.
// Start date of ranking
"rankStartDateAndTime": {
"S": "2021-03-14T15:00:00.000Z"
},
// Exists only for one-time rankings.
// End date of ranking
"rankEndDateAndTime": {
"S": "2021-03-15T05:00:00.000Z"
},
// Ranking period
// day : daily
// week : weekly
// month : monthly
// infinity : accumulative ranking
// custom : one-time ranking
"date": {
"S": "custom"
},
// Ranking uuid
"uuid": {
"S": "90c25d70-8535-11eb-b01b-af47a424fd52"
},
// How to sort ranking
// desc : descending order
// asc : ascending order
"order": {
"S": "desc"
},
// Whether to initialize the column used for the ranking upon initialization
"isReset": {
"BOOL": false
},
// Ranking name
"title": {
"S": "User ranking"
},
// Name of the table used in the ranking
"table" : {
"S": "scoreTable"
},
// Name of the column used as ranking score
"column" : {
"S":"score"
},
// Name of the column used as an additional field of the ranking(exists only when the additional item is registered)
"extraDataColumn" : {
"S":"deck"
},
// Data type of the column used as an additional field of the ranking(exists only when the additional item is registered)
// https://developer.thebackend.io/sdk-docs/backend/base/knowhow/object-for-return/data-structure/
"extraDataType" : {
"S":"M"
}
},
// and etc...
]
}

Sample code

public class RankTableItem
{
public string rankType;
public string date;
public string uuid;
public string order;
public bool isReset;
public string title;
public string table;
public string column;

//Exists only for one-time rankings
public DateTime rankStartDateAndTime;
public DateTime rankEndDateAndTime;

//Exits only when there are additional fields
public string extraDataColumn;
public string extraDataType;

public override string ToString()
{
string str = $"rankType:{rankType}\n" +
$"date:{date}\n" +
$"uuid:{uuid}\n" +
$"order:{order}\n" +
$"isReset:{isReset}\n" +
$"title:{title}\n" +
$"table:{table}\n" +
$"column:{column}\n";

if(rankStartDateAndTime != DateTime.MinValue)
{
str += $"rankStartDateAndTime:{rankStartDateAndTime}\n" +
$"rankEndDateAndTime:{rankEndDateAndTime}\n";
}

if(extraDataColumn != null)
{
str += $"extraDataColumn:{extraDataColumn}\n" +
$"extraDataType:{extraDataType}\n";
}

return str;
}
}
public void GetRankTableListTest()
{
List<RankTableItem> rankTableItemList = new List<RankTableItem>();

BackendReturnObject bro = Backend.URank.User.GetRankTableList();

if(bro.IsSuccess())
{
LitJson.JsonData rankTableListJson = bro.FlattenRows();

for(int i = 0; i < rankTableListJson.Count; i++)
{
RankTableItem rankTableItem = new RankTableItem();


rankTableItem.rankType = rankTableListJson[i]["rankType"].ToString();
rankTableItem.date = rankTableListJson[i]["date"].ToString();
rankTableItem.uuid = rankTableListJson[i]["uuid"].ToString();
rankTableItem.order = rankTableListJson[i]["order"].ToString();
rankTableItem.isReset = rankTableListJson[i]["isReset"].ToString() == "true" ? true : false;
rankTableItem.title = rankTableListJson[i]["title"].ToString();
rankTableItem.table = rankTableListJson[i]["table"].ToString();
rankTableItem.column = rankTableListJson[i]["column"].ToString();

if(rankTableListJson[i].ContainsKey("rankStartDateAndTime"))
{
rankTableItem.rankStartDateAndTime = DateTime.Parse(rankTableListJson[i]["rankStartDateAndTime"].ToString());
rankTableItem.rankEndDateAndTime = DateTime.Parse(rankTableListJson[i]["rankEndDateAndTime"].ToString());
}

if(rankTableListJson[i].ContainsKey("extraDataColumn"))
{
rankTableItem.extraDataColumn = rankTableListJson[i]["extraDataColumn"].ToString();
rankTableItem.extraDataType = rankTableListJson[i]["extraDataType"].ToString();
}

rankTableItemList.Add(rankTableItem);
Debug.Log(rankTableItem.ToString());
}
}
}