feat: add automatic subtask and test result for solution
This commit is contained in:
parent
bff19f2ddb
commit
5b7351efe0
2 changed files with 30 additions and 8 deletions
|
@ -5,13 +5,13 @@ import "time"
|
||||||
type Result int32
|
type Result int32
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Testing Result = 0
|
NotTested Result = 0 // change only with schema change
|
||||||
NotTested Result = 1
|
Accepted Result = 1
|
||||||
SystemFailDuringTesting Result = 2
|
CompilationError Result = 2
|
||||||
TimeLimitExceeded Result = 3
|
MemoryLimitExceeded Result = 3
|
||||||
MemoryLimitExceeded Result = 4
|
TimeLimitExceeded Result = 4
|
||||||
CompilationError Result = 5
|
SystemFailDuringTesting Result = 5
|
||||||
Accepted Result = 6
|
Testing Result = 6
|
||||||
)
|
)
|
||||||
|
|
||||||
func (result Result) Valid() error {
|
func (result Result) Valid() error {
|
||||||
|
|
|
@ -156,7 +156,7 @@ CREATE INDEX ON tests USING BTREE (testgroup_id);
|
||||||
CREATE TABLE IF NOT EXISTS subtaskruns
|
CREATE TABLE IF NOT EXISTS subtaskruns
|
||||||
(
|
(
|
||||||
id serial NOT NULL,
|
id serial NOT NULL,
|
||||||
subtask_id INT REFERENCES subtasks ON DELETE CASCADE,
|
subtask_id INT REFERENCES subtasks ON DELETE CASCADE,
|
||||||
solution_id INT REFERENCES solutions ON DELETE CASCADE,
|
solution_id INT REFERENCES solutions ON DELETE CASCADE,
|
||||||
result INT NOT NULL,
|
result INT NOT NULL,
|
||||||
score INT NOT NULL,
|
score INT NOT NULL,
|
||||||
|
@ -238,7 +238,26 @@ END; $$ LANGUAGE plpgsql;
|
||||||
CREATE TRIGGER new_subtask_trg AFTER INSERT ON subtasks FOR EACH ROW EXECUTE FUNCTION on_new_subtask();
|
CREATE TRIGGER new_subtask_trg AFTER INSERT ON subtasks FOR EACH ROW EXECUTE FUNCTION on_new_subtask();
|
||||||
|
|
||||||
|
|
||||||
|
CREATE FUNCTION on_new_solution() RETURNS TRIGGER
|
||||||
|
LANGUAGE plpgsql AS $$
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO subtaskruns (subtask_id,solution_id,result,score) (SELECT id,NEW.id,0,0 FROM subtasks WHERE task_id = NEW.task_id);
|
||||||
|
--INSERT INTO testruns (test_id,subtaskrun_id,result) (SELECT id,str.id,0 FROM tests WHERE testgroup_id IN (SELECT testgroup_id FROM subtasks WHERE id IN (SELECT subtask_id FROM subtaskruns AS str WHERE solution_id=NEW.id)));
|
||||||
|
RETURN NEW;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
CREATE TRIGGER on_new_solution_trg AFTER INSERT ON solutions FOR EACH ROW EXECUTE FUNCTION on_new_solution();
|
||||||
|
|
||||||
|
CREATE FUNCTION on_new_subtaskrun() RETURNS TRIGGER
|
||||||
|
LANGUAGE plpgsql AS $$
|
||||||
|
BEGIN
|
||||||
|
INSERT INTO testruns (test_id,subtaskrun_id,result) (SELECT id,NEW.id,0 FROM tests WHERE testgroup_id IN (SELECT testgroup_id FROM subtasks WHERE id=NEW.subtask_id));
|
||||||
|
RETURN NEW;
|
||||||
|
END;
|
||||||
|
$$;
|
||||||
|
|
||||||
|
CREATE TRIGGER on_new_subtaskrun_trg AFTER INSERT ON subtaskruns FOR EACH ROW EXECUTE FUNCTION on_new_subtaskrun();
|
||||||
|
|
||||||
CREATE FUNCTION updated_at_update() RETURNS TRIGGER
|
CREATE FUNCTION updated_at_update() RETURNS TRIGGER
|
||||||
LANGUAGE plpgsql AS
|
LANGUAGE plpgsql AS
|
||||||
|
@ -249,6 +268,7 @@ BEGIN
|
||||||
END;
|
END;
|
||||||
$$;
|
$$;
|
||||||
|
|
||||||
|
|
||||||
CREATE TRIGGER languages_upd_trg BEFORE UPDATE ON languages FOR EACH ROW EXECUTE FUNCTION updated_at_update();
|
CREATE TRIGGER languages_upd_trg BEFORE UPDATE ON languages FOR EACH ROW EXECUTE FUNCTION updated_at_update();
|
||||||
CREATE TRIGGER problems_upd_trg BEFORE UPDATE ON problems FOR EACH ROW EXECUTE FUNCTION updated_at_update();
|
CREATE TRIGGER problems_upd_trg BEFORE UPDATE ON problems FOR EACH ROW EXECUTE FUNCTION updated_at_update();
|
||||||
CREATE TRIGGER contests_upd_trg BEFORE UPDATE ON contests FOR EACH ROW EXECUTE FUNCTION updated_at_update();
|
CREATE TRIGGER contests_upd_trg BEFORE UPDATE ON contests FOR EACH ROW EXECUTE FUNCTION updated_at_update();
|
||||||
|
@ -260,6 +280,8 @@ DROP FUNCTION IF EXISTS updated_at_update CASCADE;
|
||||||
DROP FUNCTION IF EXISTS on_new_participant CASCADE;
|
DROP FUNCTION IF EXISTS on_new_participant CASCADE;
|
||||||
DROP FUNCTION IF EXISTS on_new_task CASCADE;
|
DROP FUNCTION IF EXISTS on_new_task CASCADE;
|
||||||
DROP FUNCTION IF EXISTS on_new_subtask CASCADE;
|
DROP FUNCTION IF EXISTS on_new_subtask CASCADE;
|
||||||
|
DROP FUNCTION IF EXISTS on_new_solution CASCADE;
|
||||||
|
DROP FUNCTION IF EXISTS on_new_subtaskrun CASCADE;
|
||||||
DROP TABLE IF EXISTS tests CASCADE;
|
DROP TABLE IF EXISTS tests CASCADE;
|
||||||
DROP TABLE IF EXISTS solutions CASCADE;
|
DROP TABLE IF EXISTS solutions CASCADE;
|
||||||
DROP TABLE IF EXISTS languages CASCADE;
|
DROP TABLE IF EXISTS languages CASCADE;
|
||||||
|
|
Loading…
Reference in a new issue