From: Marius Gavrilescu Date: Tue, 25 Mar 2014 12:42:49 +0000 (+0200) Subject: Make redis-to-postgres also copy problems which are only in a contest X-Git-Tag: 5999.000_003~19 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=20fa6cfca71c44400d5f7ec237c3e56ea83e90a3;p=gruntmaster-data.git Make redis-to-postgres also copy problems which are only in a contest --- diff --git a/db.sql b/db.sql index eafd89e..3a43eb5 100644 --- a/db.sql +++ b/db.sql @@ -25,7 +25,7 @@ CREATE TABLE contests ( CREATE TABLE problems ( id TEXT PRIMARY KEY, - author TEXT NOT NULL, + author TEXT, generator GENERATOR NOT NULL, judge JUDGE NOT NULL, level PLEVEL NOT NULL, @@ -61,7 +61,7 @@ CREATE TABLE jobs ( problem TEXT NOT NULL REFERENCES problems, result INT, result_text TEXT, - results JSON, + results TEXT, source TEXT NOT NULL, owner TEXT NOT NULL REFERENCES users ); diff --git a/redis-to-postgres b/redis-to-postgres index 330d5a6..979f324 100755 --- a/redis-to-postgres +++ b/redis-to-postgres @@ -52,6 +52,26 @@ for (contests) { }); local $Gruntmaster::OldData::contest = $_; for (problems) { + eval { + my $meta = problem_meta; + $db->problems->create({ + id => $_, + author => problem_author, + generator => problem_generator() // $meta->{generator}, + judge => problem_judge() // $meta->{judge}, + level => problem_level, + name => problem_name, + olimit => problem_olimit() // $meta->{olimit}, + owner => problem_owner, + private => (problem_private() ? 1 : 0), + runner => problem_runner() // $meta->{runner}, + statement => problem_statement, + testcnt => problem_testcnt() // $meta->{testcnt}, + timeout => problem_timeout() // $meta->{timeout}, + (problem_runner() // $meta->{runner}) eq 'File' ? (tests => encode_json $meta->{tests}) : (), + exists $meta->{files} ? (versource => $meta->{files}{ver}{content}, verformat => $meta->{files}{ver}{format}) : () + }) + }; $db->contest_problems->create({ contest => $Gruntmaster::OldData::contest, problem => $_,