Skip to content

Commit c242fa1

Browse files
authored
Merge pull request #150 from isucon/fixed-player
tenant.id=1,2でplayer_id=000[tenant.id]の固定ID playerを作る
2 parents 28d9bea + 5c401b5 commit c242fa1

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

data/data.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,9 @@ func CreatePlayers(tenant *isuports.TenantRow) []*isuports.PlayerRow {
348348
for i := 0; i < playersNum; i++ {
349349
players = append(players, CreatePlayer(tenant))
350350
}
351+
if tenant.ID <= 2 { // id 1, 2 は特別に固定のplayerを作る
352+
players = append(players, CreateFixedPlayer(tenant))
353+
}
351354
sort.SliceStable(players, func(i int, j int) bool {
352355
return players[i].CreatedAt < players[j].CreatedAt
353356
})
@@ -367,6 +370,19 @@ func CreatePlayer(tenant *isuports.TenantRow) *isuports.PlayerRow {
367370
return &player
368371
}
369372

373+
func CreateFixedPlayer(tenant *isuports.TenantRow) *isuports.PlayerRow {
374+
created := tenant.CreatedAt
375+
player := isuports.PlayerRow{
376+
TenantID: tenant.ID,
377+
ID: "000" + fmt.Sprintf("%x", tenant.ID),
378+
DisplayName: fake.Person().Name(),
379+
IsDisqualified: false,
380+
CreatedAt: created,
381+
UpdatedAt: created,
382+
}
383+
return &player
384+
}
385+
370386
func CreateCompetitions(tenant *isuports.TenantRow) []*isuports.CompetitionRow {
371387
var num int
372388
if tenant.ID == 1 {

0 commit comments

Comments
 (0)