return color by string, added rounds since maxrounds is not defined in pre-riptide matches

This commit is contained in:
2021-10-08 20:59:14 +02:00
parent cc48365eea
commit cce5c5d072
17 changed files with 283 additions and 18 deletions

View File

@@ -35,6 +35,8 @@ type Match struct {
MatchResult int `json:"match_result,omitempty"`
// MaxRounds holds the value of the "max_rounds" field.
MaxRounds int `json:"max_rounds,omitempty"`
// Rounds holds the value of the "rounds" field.
Rounds int `json:"rounds,omitempty"`
// DemoExpired holds the value of the "demo_expired" field.
DemoExpired bool `json:"demo_expired,omitempty"`
// DemoParsed holds the value of the "demo_parsed" field.
@@ -90,7 +92,7 @@ func (*Match) scanValues(columns []string) ([]interface{}, error) {
values[i] = new([]byte)
case match.FieldDemoExpired, match.FieldDemoParsed:
values[i] = new(sql.NullBool)
case match.FieldID, match.FieldScoreTeamA, match.FieldScoreTeamB, match.FieldDuration, match.FieldMatchResult, match.FieldMaxRounds:
case match.FieldID, match.FieldScoreTeamA, match.FieldScoreTeamB, match.FieldDuration, match.FieldMatchResult, match.FieldMaxRounds, match.FieldRounds:
values[i] = new(sql.NullInt64)
case match.FieldShareCode, match.FieldMap, match.FieldReplayURL:
values[i] = new(sql.NullString)
@@ -171,6 +173,12 @@ func (m *Match) assignValues(columns []string, values []interface{}) error {
} else if value.Valid {
m.MaxRounds = int(value.Int64)
}
case match.FieldRounds:
if value, ok := values[i].(*sql.NullInt64); !ok {
return fmt.Errorf("unexpected type %T for field rounds", values[i])
} else if value.Valid {
m.Rounds = int(value.Int64)
}
case match.FieldDemoExpired:
if value, ok := values[i].(*sql.NullBool); !ok {
return fmt.Errorf("unexpected type %T for field demo_expired", values[i])
@@ -247,6 +255,8 @@ func (m *Match) String() string {
builder.WriteString(fmt.Sprintf("%v", m.MatchResult))
builder.WriteString(", max_rounds=")
builder.WriteString(fmt.Sprintf("%v", m.MaxRounds))
builder.WriteString(", rounds=")
builder.WriteString(fmt.Sprintf("%v", m.Rounds))
builder.WriteString(", demo_expired=")
builder.WriteString(fmt.Sprintf("%v", m.DemoExpired))
builder.WriteString(", demo_parsed=")