UpdateUserScore
public BackendReturnObject UpdateUserScore(string rankUuid, string tableName, string rowIndate, Param param);
The URank ranking method can only register NULL groups in grouped leaderboards.
If you want to register leaderboards according to groups, use the Leaderboard method.
If a table registered to a ranking is changed to Public, 400 bad public Table error will occur and data will not be updated.
As such, we advise you to not change a registered table's status to Public.
Parameters
Value | Type | Description |
---|---|---|
rankUuid | string | uuid of the ranking to update |
tableName | string | Name of the table to update |
rowIndate | string | inDate of the row to update |
param | Param | Value to update |
The rankUuid value can be checked using the following methods:
- Create a ranking in BACKND Console and check the uuid value from the information of the ranking
- Check the uuid value using the Look up ranking information of all users method
Description
Updates the uuid ranking as well as the data stored in the row of the table.
- To update the ranking, the user to perform the task must insert the relevant table once and create a row.
- In rowIndate, the inDate value of the inserted row must be indicated.
- UpdateUserScore is a method where the ranking update function is added to the Backend.GameData.Update method.
- Data updated without using the UpdateUserScore method is not reflected in the ranking (regardless of the ranking score and additional fields).
The param must meet the following conditions:
- When generating a ranking, the value of the selected column must be included.
The range of column values selected when creating a ranking (values to be used as scores) must be as follows. Values out of that range may not be stored properly (e.g., rounded up or down), and cause an error when looking up the ranking in the SDK.
Integer: -9007199254740992 - 9007199254740992 (-2^53 ~ 2^53)
Real number: -3.40282347E+38F - 3.40282347E+38F (float.MinValue ~ float.MaxValue)
Additional field
- When generating a ranking, the column of the selected additional field does not have to be included.
- Other columns may be included as well.
- The value to be updated in the table is determined by the schema definition/non-definition rule of each table.
- Additional fields can contain up to 256byte of data, and an error will occur if 257 bytes or larger sized data is registered.
- Even if the param does not include additional fields, the additional fields are registered to the ranking if they exist in the rowIndate's data.
The param must meet the following conditions:
- When generating a ranking, the value of the selected column must be included.
The range of column values selected when creating a ranking (values to be used as scores) must be as follows.
Values out of that range may not be stored properly (e.g., rounded up or down), and cause an error when looking up the ranking in the SDK.
Integer: -9007199254740992 - 9007199254740992 (-2^53 ~ 2^53)
Real number: -3.40282347E+38F - 3.40282347E+38F (float.MinValue ~ float.MaxValue) - When generating a ranking, the column of the selected additional field does not have to be included.
- Other columns may be included as well.
- The value to be updated in the table is determined by the schema definition/non-definition rule of each table.
Example
Synchronous
Param param = new Param();
param.Add("score", i);
param.Add("extraData", "additional info");
Backend.URank.User.UpdateUserScore("ranking uuid", "table name", "inDate of the row to update", param);
Asynchronous
Param param = new Param();
param.Add("score", i);
param.Add("extraData", "additional info");
Backend.URank.User.UpdateUserScore("ranking uuid", "table name", "inDate of the row to update", param, callback =>
{
// Post-process
});
SendQueue
Param param = new Param();
param.Add("score", i);
param.Add("extraData", "additional info");
SendQueue.Enqueue(Backend.URank.User.UpdateUserScore, "ranking uuid", "table name", "inDate of the row to update", param, callback =>
{
// Post-process
});
ReturnCase
Success cases
When successful
statusCode : 204
message : Success
Error cases
(Schema) When the data type of the column that declared the schema is different from the data type of the column inserted to param
statusCode : 400
errorCode : BadParameterException
message : bad {data type of the column} dataType, Invalid {data type of the column} dataType
When the uuid is null or string.Empty
statusCode : 400
errorCode : ValidationException
message : rankUuid is null or empty
When the table is not the one registered as a ranking field upon creating the ranking
statusCode : 400
errorCode : BadParameterException
message : bad table, Invalid table
When the ranking to be updated is not a user ranking
statusCode : 400
errorCode : BadParameterException
message : bad table, Invalid table
When the inDate is null or string.Empty
statusCode : 400
errorCode : BadParameterException
message : bad inDate must be, Invalid inDate
When the column registered as a ranking field upon creating the ranking is not in param
statusCode : 400
errorCode : BadParameterException
message : bad rankData column, Invalid rankData column
When updated to a value other than int, long double, and float
statusCode : 400
errorCode : BadParameterException
message : bad value must number, The value must be a number
(Schema) When a column whose schema is not declared is in param
statusCode : 404
errorCode : NotFoundException
message : column not found, column cannot be found
When a non-existent inDate is entered / When another person's row Indate is entered
statusCode : 404
errorCode : NotFoundException
message : data not found, data cannot be found
When there is an attempt to update the ranking during UTC +9 04:00 - 05:00
statusCode : 428
errorCode : Precondition Required
message : Precondition Required ranking is being counted
When there is an attempt to update the ranking between 4 am - 5 am in Korean time
When the user tries to renew an expired one-time ranking
statusCode : 428
errorCode : Precondition Required
message : Precondition Required ranking is being counted
Sample Code
public void GetUpdateUserRankTest()
{
string tableName = "score";
string rowIndate = string.Empty;
string rankingUUID = "fe8ffa20-1db6-11ec-83a0-77f4e266a1f3";
Param param = new Param();
param.Add("score", 10);
var bro = Backend.GameData.Get("score", new Where());
if(bro.IsSuccess())
{
if(bro.FlattenRows().Count > 0)
{
rowIndate = bro.FlattenRows()[0]["inDate"].ToString();
}
else
{
var bro2 = Backend.GameData.Insert(tableName, param);
if(bro2.IsSuccess())
{
rowIndate = bro2.GetInDate();
}
else
{
return;
}
}
}
else
{
return;
}
if(rowIndate == string.Empty)
{
return;
}
var rankBro = Backend.URank.User.UpdateUserScore(rankingUUID, tableName, rowIndate, param);
if(rankBro.IsSuccess())
{
Debug.Log("Ranking registration successful");
}
else
{
Debug.Log("Ranking registration failed : " + rankBro);
}
}