feat: add rejudge function to storage & update schema
This commit is contained in:
parent
80df2e2820
commit
48ad3a5461
3 changed files with 41 additions and 3 deletions
|
@ -24,6 +24,10 @@ func NewSolutionStorage(db *sqlx.DB, logger *zap.Logger) *SolutionStorage {
|
|||
}
|
||||
}
|
||||
|
||||
//func updateResult(ctx context.Context, participant_id int32, task_id int32) error {
|
||||
//
|
||||
//}
|
||||
|
||||
func (storage *SolutionStorage) CreateSolution(ctx context.Context, solution *models.Solution) (int32, error) {
|
||||
query := storage.db.Rebind(`
|
||||
INSERT INTO solutions
|
||||
|
@ -65,6 +69,19 @@ func (storage *SolutionStorage) ReadSolutionById(ctx context.Context, id int32)
|
|||
return &solution, nil
|
||||
}
|
||||
|
||||
func (storage *SolutionStorage) RejudgeSolution(ctx context.Context, id int32) error {
|
||||
query := storage.db.Rebind("UPDATE solutions SET result = ? WHERE id = ?")
|
||||
_, err := storage.db.ExecContext(ctx, query, models.NotTested, id)
|
||||
query := storage.db.Rebind("UPDATE testruns SET result = ? WHERE solution_id = ?")
|
||||
_, err := storage.db.ExecContext(ctx, query, models.NotTested, id)
|
||||
//FIXME: update result
|
||||
if err != nil {
|
||||
return storage.HandlePgErr(err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (storage *SolutionStorage) DeleteSolution(ctx context.Context, id int32) error {
|
||||
query := storage.db.Rebind("DELETE FROM solutions WHERE id=?")
|
||||
_, err := storage.db.ExecContext(ctx, query, id)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue