Commit c288ecb2 authored by Mo Firouz's avatar Mo Firouz
Browse files

Add tournament start active timestamp to the API response.

parent 0abe3796
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -7,6 +7,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
### Added
- Explicitly set cache control header in all API responses.
- Add support for CockroachDB 19.1.
- Add tournament start active timestamp to the API response.

### Changed
- Tournament start time can be set to past time.
+221 −211

File changed.

Preview size limit exceeded, changes collapsed.

+2 −0
Original line number Diff line number Diff line
@@ -784,6 +784,8 @@ message Tournament {
  google.protobuf.Timestamp end_time = 15;
  // The UNIX timestamp for duration of a tournament.
  uint32 duration = 16;
  // The UNIX timestamp when the tournament start being active. A computed value.
  uint32 start_active = 17;
}

// A list of tournaments.
+5 −0
Original line number Diff line number Diff line
@@ -3043,6 +3043,11 @@
          "type": "integer",
          "format": "int64",
          "description": "The UNIX timestamp for duration of a tournament."
        },
        "start_active": {
          "type": "integer",
          "format": "int64",
          "description": "The UNIX timestamp when the tournament start being active. A computed value."
        }
      },
      "description": "A tournament on the server."
+3 −2
Original line number Diff line number Diff line
@@ -528,9 +528,9 @@ func parseTournament(scannable Scannable, now time.Time) (*api.Tournament, error
	canEnter := true
	endTime := dbEndTime.Time.UTC().Unix()

	_, endActiveUnix, expiryUnix := calculateTournamentDeadlines(dbStartTime.Time.UTC().Unix(), endTime, int64(dbDuration), resetSchedule, now)
	startActive, endActiveUnix, expiryUnix := calculateTournamentDeadlines(dbStartTime.Time.UTC().Unix(), endTime, int64(dbDuration), resetSchedule, now)

	if endActiveUnix < now.Unix() {
	if startActive > now.Unix() || endActiveUnix < now.Unix() {
		canEnter = false
	}

@@ -554,6 +554,7 @@ func parseTournament(scannable Scannable, now time.Time) (*api.Tournament, error
		CreateTime:  &timestamp.Timestamp{Seconds: dbCreateTime.Time.UTC().Unix()},
		StartTime:   &timestamp.Timestamp{Seconds: dbStartTime.Time.UTC().Unix()},
		Duration:    uint32(dbDuration),
		StartActive: uint32(startActive),
	}

	if endTime > 0 {
Loading