Hi, Himanshu Sharma Rankings error occurs during storage. Could you tell me how effective?
Error Message
Status: 400
Output: {"failure" : "true", "message" : {"app42Fault":{"httpErrorCode":400,"appErrorCode":1904,"message":"Bad Request","details":" Application Exception : Request Execution Time Exceeded threashold value "}}, "errorCode":400}
public class RankBackupAll implements Executor
{
private ServiceAPI sp = new ServiceAPI( Constants.App42ApiKey, Constants.App42ApiSecret);
private final int HTTP_STATUS_SUCCESS = 200;
private String moduleName = "RankBackupAll";
@Override
public HttpResponseObject execute(HttpRequestObject request)
{
GameService gameService = sp.buildGameService();
ScoreBoardService scoreBoardService = sp.buildScoreBoardService();
StorageService storageService = sp.buildStorageService();
int max = 50;
List<Game> games = gameService.getAllGames();
for( int i=0; i<games.size(); i++)
{
String gamename = games.get(i).getName();
try{
JSONObject j = new JSONObject();
j.put(gamename, gamename);
j.put("CNT", 0);
try{
Game game = scoreBoardService.getTopNRankers( gamename, max);
j.put("CNT", game.getScoreList().size());
for (int g = 0; g < game.getScoreList().size(); g++)
{
Storage st = storageService.findDocumentByKeyValue("WW1DB", "Users", "UUID", game.getScoreList().get(g).getUserName() );
JSONObject js = new JSONObject(st.getJsonDocList().get(0).getJsonDoc());
j.put("nick"+g, js.get("nick"));
j.put("Lan"+g, js.getString("Lan"));
j.put("score"+g, game.getScoreList().get(g).getValue());
}
}catch (App42Exception ee)
{}
try{
storageService.updateDocumentByKeyValue( "WW1DB", "Ranks", gamename, gamename, j );
}catch(App42Exception e){
storageService.insertJSONDocument( "WW1DB", "Ranks", j );
}
} catch (JSONException e) {}
}
JSONObject jsonResponse = new JSONObject();
try {
jsonResponse.put("moduleName", moduleName );
} catch (JSONException e) {
}
return new HttpResponseObject(HTTP_STATUS_SUCCESS, jsonResponse);
}
}