Skip to content

Commit

Permalink
Merge pull request #150 from isucon/fixed-player
Browse files Browse the repository at this point in the history
tenant.id=1,2でplayer_id=000[tenant.id]の固定ID playerを作る
  • Loading branch information
fujiwara authored Jul 9, 2022
2 parents 28d9bea + 5c401b5 commit c242fa1
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions data/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ func CreatePlayers(tenant *isuports.TenantRow) []*isuports.PlayerRow {
for i := 0; i < playersNum; i++ {
players = append(players, CreatePlayer(tenant))
}
if tenant.ID <= 2 { // id 1, 2 は特別に固定のplayerを作る
players = append(players, CreateFixedPlayer(tenant))
}
sort.SliceStable(players, func(i int, j int) bool {
return players[i].CreatedAt < players[j].CreatedAt
})
Expand All @@ -367,6 +370,19 @@ func CreatePlayer(tenant *isuports.TenantRow) *isuports.PlayerRow {
return &player
}

func CreateFixedPlayer(tenant *isuports.TenantRow) *isuports.PlayerRow {
created := tenant.CreatedAt
player := isuports.PlayerRow{
TenantID: tenant.ID,
ID: "000" + fmt.Sprintf("%x", tenant.ID),
DisplayName: fake.Person().Name(),
IsDisqualified: false,
CreatedAt: created,
UpdatedAt: created,
}
return &player
}

func CreateCompetitions(tenant *isuports.TenantRow) []*isuports.CompetitionRow {
var num int
if tenant.ID == 1 {
Expand Down

0 comments on commit c242fa1

Please sign in to comment.