Unverified Commit c8f89a65 authored by Simon Esposito's avatar Simon Esposito Committed by GitHub
Browse files

Fix tournament active end calculation error (#568)

Correctly calculate the end active time for a tournament with no reset schedule set.
parent 79940f82
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -628,14 +628,11 @@ func calculateTournamentDeadlines(startTime, endTime, duration int64, resetSched
		return startActiveUnix, endActiveUnix, expiryUnix
	}

	endActiveUnix := int64(0)
	if startTime <= tUnix {
		endActiveUnix = startTime + duration
	}
	endActiveUnix := startTime + duration
	expiryUnix := endTime
	if expiryUnix > 0 && endActiveUnix > expiryUnix {
	if endTime > 0 && endActiveUnix > endTime {
		// Cap the end active to the same time as the expiry.
		endActiveUnix = expiryUnix
		endActiveUnix = endTime
	}
	return startTime, endActiveUnix, expiryUnix
}
+1 −1
Original line number Diff line number Diff line
@@ -189,7 +189,7 @@ func (ls *LocalLeaderboardScheduler) Update() {
	expiryLeaderboardIds := make([]string, 0, 1)

	for _, l := range leaderboards {
		if l.Duration > 0 {
		if l.IsTournament() {
			// Tournament.
			_, endActive, expiry := calculateTournamentDeadlines(l.StartTime, l.EndTime, int64(l.Duration), l.ResetSchedule, now)

+0 −7
Original line number Diff line number Diff line
@@ -5679,13 +5679,6 @@ func getJsAccountData(account *api.Account) (map[string]interface{}, error) {
	}
	accountData["user"] = userData

	metadata := make(map[string]interface{})
	err = json.Unmarshal([]byte(account.User.Metadata), &metadata)
	if err != nil {
		return nil, fmt.Errorf("failed to convert metadata to json: %s", err.Error())
	}
	accountData["metadata"] = metadata

	walletData := make(map[string]int64)
	err = json.Unmarshal([]byte(account.Wallet), &walletData)
	if err != nil {