Sign In Register

How can we help you today?

Start a new topic
Answered

Time based leaderboards, last n days clarification

I've been experimenting with time based leaderboards by following the tutorial. It works fine but I wanted to be sure if I understand correctly the dynamics of it.


In the tutorial, the example states it's been built for the last 30 days. But in my tests, the name of the snapshot is {leaderboard_name}..SNAPSHOT.2017-03-01, i.e the beginning of the month.


So I have a conflicting model in my mind of the concepts of monthly updating / resetting leaderboards, which are set to the beginning of the month, and the time filter we created in the format of: ${now - 30 * 24 * 60 * 60 * 1000} which is the last 30 days.


Same question stands for last 7 days and last 24 hours as well.


Thanks


Best Answer

 Hello forum peopliii!

I just wanted to share Liam's solution here so that it will help you guys if you also come across the problem....

Hi Selim,


No problem. You can set up event as follows. We have a won and lost value and some time values with default value expressions so the dates will automatically be added to scores


image


For day we're using ${format(today, 'yyyyMMdd')} //for today it'll return "20170329"

For week we're using ${format(today, 'yyyyww')} //for this week it will return "201714"

For month we're using ${format(today, 'yyyymm')} //for this month it will return "201703"


No you can create you leaderboards like below. 


Day

image


Week

image


Month

image


With these in place you are now ready to post a score. When you test this in the test harness you notice it looks like this.


{

  "@class": ".LogEventRequest",

  "eventKey": "points_LB",

  "pointsWon": 0,

  "pointsLost": 0,

  "day": "${format(today, 'yyyyMMdd')}",

  "week": "${format(today, 'yyyyww')}",

  "month": "${format(today, 'yyyyMM')}"

}


You can remove the day/week/month default values when sending this event. You' only need to send it with the won and lost attributes.


{

  "@class": ".LogEventRequest",

  "eventKey": "points_LB",

  "pointsWon": 0,

  "pointsLost": 0

}


Once posted you can check out the results in the leaderboard manage screen. With this system a partition will be created for each unique day/week/month value that gets automatically passed in from the event. Try that and let me know if it work as expected.


Regards,

Liam


Hi Selim,


I've followed up with you in your ticket on this issue.


Regards,

Liam

Answer

 Hello forum peopliii!

I just wanted to share Liam's solution here so that it will help you guys if you also come across the problem....

Hi Selim,


No problem. You can set up event as follows. We have a won and lost value and some time values with default value expressions so the dates will automatically be added to scores


image


For day we're using ${format(today, 'yyyyMMdd')} //for today it'll return "20170329"

For week we're using ${format(today, 'yyyyww')} //for this week it will return "201714"

For month we're using ${format(today, 'yyyymm')} //for this month it will return "201703"


No you can create you leaderboards like below. 


Day

image


Week

image


Month

image


With these in place you are now ready to post a score. When you test this in the test harness you notice it looks like this.


{

  "@class": ".LogEventRequest",

  "eventKey": "points_LB",

  "pointsWon": 0,

  "pointsLost": 0,

  "day": "${format(today, 'yyyyMMdd')}",

  "week": "${format(today, 'yyyyww')}",

  "month": "${format(today, 'yyyyMM')}"

}


You can remove the day/week/month default values when sending this event. You' only need to send it with the won and lost attributes.


{

  "@class": ".LogEventRequest",

  "eventKey": "points_LB",

  "pointsWon": 0,

  "pointsLost": 0

}


Once posted you can check out the results in the leaderboard manage screen. With this system a partition will be created for each unique day/week/month value that gets automatically passed in from the event. Try that and let me know if it work as expected.


Regards,

Liam

Login to post a comment