Commit 4144913c authored by Andrei Mihu's avatar Andrei Mihu
Browse files

Fix time parameter in leaderboard and tournament callbacks.

parent 355271cd
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,9 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
- Use correct parameter name for lang tag in group update queries.
- Do not allow users to send friend requests to the root user.
- Tournament listings now report correct active periods if the start time is in the future.
- Leaderboard and tournament reset runtime callbacks now receive the correct reset time.
- Tournament end runtime callbacks now receive the correct end time.
- Leaderboard and tournament runtime callbacks no longer trigger twice when time delays are observed.

## [2.2.1] - 2018-11-20
### Added
+4 −4
Original line number Diff line number Diff line
@@ -198,12 +198,12 @@ func (ls *LocalLeaderboardScheduler) Update() {

	endActiveDuration := time.Duration(-1)
	if earliestEndActive > -1 {
		endActiveDuration = time.Unix(earliestEndActive, 0).UTC().Sub(now)
		endActiveDuration = time.Unix(earliestEndActive, 0).UTC().Sub(now) + time.Second
	}

	expiryDuration := time.Duration(-1)
	if earliestExpiry > -1 {
		expiryDuration = time.Unix(earliestExpiry, 0).UTC().Sub(now)
		expiryDuration = time.Unix(earliestExpiry, 0).UTC().Sub(now) + time.Second
	}

	// Replace IDs earmarked for end and expiry, and restart timers as needed.
@@ -230,13 +230,13 @@ func (ls *LocalLeaderboardScheduler) Update() {
	if endActiveDuration > -1 {
		ls.logger.Debug("Setting timer to run end active function", zap.Duration("end_active", endActiveDuration), zap.Strings("ids", ls.nearEndActiveIds))
		ls.endActiveTimer = time.AfterFunc(endActiveDuration, func() {
			ls.invokeEndActiveElapse(time.Unix(earliestEndActive, 0).UTC())
			ls.invokeEndActiveElapse(time.Unix(earliestEndActive-1, 0).UTC())
		})
	}
	if expiryDuration > -1 {
		ls.logger.Debug("Setting timer to run expiry function", zap.Duration("expiry", expiryDuration), zap.Strings("ids", ls.nearExpiryIds))
		ls.expiryTimer = time.AfterFunc(expiryDuration, func() {
			ls.invokeExpiryElapse(time.Unix(earliestExpiry, 0).UTC())
			ls.invokeExpiryElapse(time.Unix(earliestExpiry-1, 0).UTC())
		})
	}
	ls.Unlock()