Leaderboard Scheduling

Leaderboard Scheduling#

Leaderboard Scheduling allows users to schedule a leaderboard reset and/or re-rank.

(Un)Scheduling#

Scheduling functionality is a part of the Leaderboard creation process. Running Leaderboard->ResetSchedule removes all entries from the leaderboard in real-time, according to when it’s scheduled.

To schedule a Leaderboard Reset, we must set the schedule using LeaderboardService’s ResetSchedule value; when a leaderboard is created:

Leaderboard leaderboard = new()
{
    Name = "Leaderboard",
    SortBy = Leaderboard.SCORE_SORT_BY,
    ResetSchedule = "0 0 * * 7",
};

leaderboard = await boardService.Create(leaderboard);

Running Leaderboard->RankingSchedule re-orders the leaderboard in real-time, according to when it’s scheduled. To schedule a Leaderboard Re-Rankin, we must set the schedule using LeaderboardService’s RankingSchedule value; when a leaderboard is created.

Leaderboard leaderboard = new()
{
  Name = "Leaderboard",
  SortBy = Leaderboard.SCORE_SORT_BY,
  RankingSchedule = "0 0 * * 7",
};

leaderboard = await boardService.Create(leaderboard);

It is best to stagger these schedules, so they do not happen at the same time. Both are string variables and follow standard cron-job expressions.

Cron-Job Expressions#

Cron-Job expressions are a standardized format for scheduling automatically run server processes. If a user wants a server to remove all entries from a database at a certain time repeatedly; Cron Job expressions are used.

Format#

<minute> <hour> <day-of-the-month> <month> <day-of-the-week>

Values#

  • <<Number>> - Specifies the time unit to run

  • <*> - Specifies Running Every time unit

  • <?> - Specifies that this can run at any time for the time unit.

  • <-> - Specifies a range of times it can run for that time unit

  • <,> - Specifies multiple times for that time unit

  • </> - Specifies incremental values of the time unit

Example#

ResetSchedule = "0 0 * * 7"
  • 0 <minute> means run on first minute

  • 0 <hour> means run on the first hour

    • <day-of-the-month> means every day of the month

    • <month> means every month of the year

  • 7 <day-of-the-week> on Sunday

I.E. ResetSchedule = "0 0 * * 7"

This means the Leaderboard will reset at midnight every:

  • Sunday

  • Week

  • Month

  • Year