Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions go/isuports.go
Original file line number Diff line number Diff line change
Expand Up @@ -1143,25 +1143,34 @@ func competitionScoreHandler(c echo.Context) error {
return fmt.Errorf("error Delete player_score: tenantID=%d, competitionID=%s, %w", v.tenantID, competitionID, err)
}

valueQuery := ""
values := make([]interface{}, 0)
for _, ps := range playerScoreRows {
if valueQuery != "" {
valueQuery += ","
g := 100

for start := 0; start < len(playerScoreRows); start += g {
valueQuery := ""
values := make([]interface{}, 0)
end := start + g
if end > len(playerScoreRows) {
end = len(playerScoreRows)
}
for i := start; i < end; i++ {
if valueQuery != "" {
valueQuery += ","
}
ps := playerScoreRows[i]
valueQuery += "(?, ?, ?, ?, ?, ?, ?, ?)"
values = append(values, ps.ID, ps.TenantID, ps.PlayerID, ps.CompetitionID, ps.Score, ps.RowNum, ps.CreatedAt, ps.UpdatedAt)
}
valueQuery += "(?, ?, ?, ?, ?, ?, ?, ?)"
values = append(values, ps.ID, ps.TenantID, ps.PlayerID, ps.CompetitionID, ps.Score, ps.RowNum, ps.CreatedAt, ps.UpdatedAt)
}

if _, err := tenantDB.ExecContext(
ctx,
"INSERT INTO player_score (id, tenant_id, player_id, competition_id, score, row_num, created_at, updated_at) VALUES "+valueQuery,
values...,
); err != nil {
return fmt.Errorf(
"error Insert player_scores: %w",
err,
)
if _, err := tenantDB.ExecContext(
ctx,
"INSERT INTO player_score (id, tenant_id, player_id, competition_id, score, row_num, created_at, updated_at) VALUES "+valueQuery,
values...,
); err != nil {
return fmt.Errorf(
"error Insert player_scores: %w",
err,
)
}
}

fl.Close() // it's done
Expand Down