How to set start and end time for daily leaderboard.

0 votes

Hi, 


I try to retrieve usernames id-s and scores for my daily leaderboard, but i can't see them when i set start/end time filter. Maybe my code is wrong. Cound you help me:

 

System.DateTime current_time = time.GetCurrentTime().ToUniversalTime();

System.DateTime start_date = new System.DateTime(current_time.Year , current_time.Month , current_time.Day , 0 , 0 , 0);
System.DateTime end_date = new System.DateTime(current_time.Year , current_time.Month , current_time.Day , 23 , 59 , 0);
 
leader.GetTopNRankers ("Challenge", start_date  , end_date , 20 , gs );
asked Aug 20, 2015 in App42 Cloud API-BaaS by Arm Nomads (10 points)

1 Answer

0 votes

Hello Arm,

 

To get the leaderboard based on start date and end date, you need to pass both date in UTC format. So please find a below code snippet to get the UTC format in which you can send date object which you have created. If you still face any issue, then please share the mehod logs with us:

public static String GetUTCFormattedTimestamp(DateTime dt)
     {
         DateTime datTimeUTC = dt;
         DateTime dtFormat = new DateTime(datTimeUTC.Year, datTimeUTC.Month, datTimeUTC.Day, datTimeUTC.Hour, datTimeUTC.Minute, datTimeUTC.Second, datTimeUTC.Millisecond);
         return String.Format("{0:yyyy-MM-dd'T'HH:mm:ss.fff'Z'}", dtFormat);
     }

To print the method logs, put the below line of code before making a request of leaderboard call:

App42Log.SetDebug(true);

 

Regards,

Himanshu Sharma

answered Aug 20, 2015 by hs00105 (2,005 points)
But our time already in utc format  ,  is my code wrong ? what is the difference with mine and yours?
Could you please print the time which you are creating because i don't have the time object which you have shared.

In addition to your code snippet, App42 leaderboard method required time zone which contain this format ({0:yyyy-MM-dd'T'HH:mm:ss.fff'Z'}). So please verify it, if the format is same than please share the internal logs of App42 method. So that we can find the root cause of this issue.

Regards,
Himanshu Sharma

Regards,
Himanshu Sharma
Ok , finally we fix time format problem , but now logs says that
there were not any scores between my time range ,  but i check my leaderboard ,  and  there are many scores in my time range .  So how to solve this ?  is this a server side problem ,  or  maybe big delay (if yes , how long is it) ?


here is code

public void OnSuccess(object response)  
{  
    Timer time = (Timer) response;
    System.DateTime current_time = time.GetCurrentTime().ToUniversalTime();
       
    System.DateTime start_date = new System.DateTime(current_time.Year , current_time.Month , current_time.Day , 0 , 1 , 0 , 0 , System.DateTimeKind.Utc);
    System.DateTime end_date = new System.DateTime(current_time.Year , current_time.Month , current_time.Day , 23 , 59 , 0 , 0 , System.DateTimeKind.Utc);

    string str_1 = string.Format("{0:yyyy-MM-dd'T'HH:mm:ss.fff'Z'}", start_date);
    string str_2 = string.Format("{0:yyyy-MM-dd'T'HH:mm:ss.fff'Z'}", end_date);

    System.DateTime start_date_2 = System.DateTime.Parse(str_1);
    System.DateTime end_date_2 = System.DateTime.Parse(str_2);

    ScoreBoardService leader = App42API.BuildScoreBoardService ();
    Game_Service gs = new Game_Service();
    leader.GetTopNRankers("Chalenge", start_date_2  , end_date_2 , 5 , gs );

}




the log

Exception : com.shephertz.app42.paas.sdk.csharp.App42NotFoundException: {"httpErrorCode":"404", "appErrorCode":"3015", "message":"Not Found", "details":"Scores betweem startDate 'Sun Aug 23 04:01:00 UTC 2015' and endDate 'Mon Aug 24 03:59:00 UTC 2015' for the game with the name 'Chalenge' does not exist."}
Hello Arm,

Could you please share your app name and game name at support@shephertz.com ? it will help us to see the root cause of this issue.

P.S There will be a lag of few hours, which we mentioned in the documentation as well. You can find from here (http://api.shephertz.com/app42-docs/leaderboard-service/#get-top-n-rankers-by-date).


Regards,
Himanshu Sharma
Download Widgets
Welcome to ShepHertz Product line forum, where you can ask questions and receive answers from the community. You can also reach out to us on support@shephertz.com
...