Skip to main content
Version: 5.9.6

GetRandomData

public BackendReturnObject GetRandomData(RandomType randomType, string uuid, int pivot, int gap, int count);

Description

Randomly calls the data that exists in the uuid according to set conditions.

The conditions are as follows:

  • pivot: the pivotal value
  • gap: the range of placements above and below based on the placement identical or closest to the pivot
  • count: number of data to be called

If the score registered on the random lookup is in the order of 10,000, 1,000, 100, 10, and 1 with the pivot as 100 and gap as 1, the random search will be conducted between the second(1,000 points) and fourth(10 points) places based on the third place with 100 points, not randomly between pieces of data with 99 - 101 points.

If the number of data cases that fit the conditions is below the count, then those pieces of data may be loaded.

You can set the gap from a minimum of 0 to a maximum of 10; the data is searched after reconfiguring the minimum and maximum values if you exceed the range.
You can set the count from a minimum of 1 to a maximum of 10; the data is searched after reconfiguring the minimum and maximum values if you exceed the range.
You can set the pivot up to the maximum value of 'long'(9223372036854775807, below 1.0E+17); the data is searched after reconfiguring the minimum and maximum values if you exceed the range.

Nicknames will not be provided and only inDate of the user/guild will be given.

Parameters

ValueTypeDescription
randomTypeRandomTypeRandom lookup type
(RandomType.User refers to the user and RandomType.Guild refers to the guild)
uuidstringUuid of the random lookup
pivotint/long/float/doublePivotal value
gapintThe range of placements above and below based on the placement identical or closest to the pivot
countintNumber of data to be called

Example

Synchronous

Backend.RandomInfo.GetRandomData(RandomType.User, "7244eca0-f67c-11ec-9eb6-490af390b219", 20,10, 5);

Asynchronous

Backend.RandomInfo.GetRandomData(RandomType.User, 
"7244eca0-f67c-11ec-9eb6-490af390b219", 20, 10, 5, (callback) => {
// Post-process
});

SendQueue

SendQueue.Enqueue(Backend.RandomInfo.GetRandomData, RandomType.User, 
"7244eca0-f67c-11ec-9eb6-490af390b219", 20, 10, 5, (callback) => {
// Post-process
});

Return cases

Success cases

When the lookup is successful
statusCode : 200

returnValue : refer to GetReturnValuetoJSON

When there is no user/guild that meets the conditions
statusCode : 200

returnValue : {"rows":[]}

Error cases

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

When the type of the random lookup is different(designated as RandomType.Guild when it is user type)
statusCode : 400
errorCode : BadParameterException

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

GetReturnValuetoJSON

If the random type(RandomType) is User

{
"rows": [
{
"gamerInDate": "2022-06-30T10:06:32.327Z",
"score": "13"
},
{
"gamerInDate": "2022-06-30T10:06:34.024Z",
"score": "19"
},
...
]
}

If the random type(RandomType) is Guild

{
"rows": [
{
"guildName": "match7GG",
"guildInDate": "2022-07-11T05:51:47.687Z",
"score": "7"
},
{
"guildName": "match12GG",
"guildInDate": "2022-07-11T05:51:53.144Z",
"score": "12"
},
...
]
}

Sample code

public class RandomInformation {

public string inDate; // inDate
public int score; // Score
public string guildName; //(only applies to guilds) Guild name

public override string ToString() {
string str = $"inDate: {inDate}\n" +
$"score: {score}";
if(!string.IsNullOrEmpty(guildName)) {
str += $"\nguildName : {guildName}";
}
return str;
}
}
public void GetRandomData() {

RandomType type = RandomType.Guild;
var bro = Backend.RandomInfo.GetRandomData(type, "96ab48f0-fce9-11ec-a8e9-3fc17cd7d4bd", 10, 10, 10);

if(bro.IsSuccess()) {

List<RandomInformation> list = new List<RandomInformation>();
LitJson.JsonData json = bro.Rows();

for(int i = 0; i < json.Count; i++) {

RandomInformation randomInformation = new RandomInformation();

if(type == RandomType.User) {
randomInformation.inDate = json[i]["gamerInDate"].ToString();
}
else {
randomInformation.guildName = json[i]["guildName"].ToString();
randomInformation.inDate = json[i]["guildInDate"].ToString();
}

randomInformation.score = int.Parse(json[i]["score"].ToString());

list.Add(randomInformation);
}
foreach(var info in list) {
Debug.Log(info.ToString());
}
}
else {
Debug.LogError("random lookup error : " + bro.ToString());
}
}