feat(tester): add UpdateContest endpoint

This commit is contained in:
Vyacheslav1557 2025-03-07 17:04:19 +05:00
parent 2bc625363d
commit e1720e7f82
8 changed files with 45 additions and 1 deletions

View file

@ -212,3 +212,19 @@ func (r *ContestRepository) ListParticipants(ctx context.Context, contestId int3
return participants, count, nil
}
const (
updateContestQuery = "UPDATE contests SET title = COALESCE(?, title) WHERE id = ?"
)
func (r *ContestRepository) UpdateContest(ctx context.Context, id int32, contestUpdate models.ContestUpdate) error {
const op = "ContestRepository.UpdateContest"
query := r.db.Rebind(updateContestQuery)
_, err := r.db.ExecContext(ctx, query, contestUpdate.Title, id)
if err != nil {
return handlePgErr(err, op)
}
return nil
}