X-Git-Url: http://git.ieval.ro/?a=blobdiff_plain;f=lib%2FGruntmaster%2FData%2FResult%2FProblem.pm;h=6359b99af1740672be8e88f8842f5a42facfee79;hb=adb42d4d148fdb3dd145e4a7452b7b7eda88f66c;hp=6b12ac552951d3fd18723f2428eb96f449e15a8e;hpb=b2725d9d3f2603f7adfa0743862d666e21b1cd32;p=gruntmaster-data.git diff --git a/lib/Gruntmaster/Data/Result/Problem.pm b/lib/Gruntmaster/Data/Result/Problem.pm index 6b12ac5..6359b99 100644 --- a/lib/Gruntmaster/Data/Result/Problem.pm +++ b/lib/Gruntmaster/Data/Result/Problem.pm @@ -31,24 +31,26 @@ __PACKAGE__->table("problems"); =head2 author data_type: 'text' - is_nullable: 0 + is_nullable: 1 + +=head2 writer + + data_type: 'text' + is_nullable: 1 =head2 generator - data_type: 'enum' - extra: {custom_type_name => "generator",list => ["File","Run","Undef"]} + data_type: 'text' is_nullable: 0 =head2 judge - data_type: 'enum' - extra: {custom_type_name => "judge",list => ["Absolute","Points"]} + data_type: 'text' is_nullable: 0 =head2 level - data_type: 'enum' - extra: {custom_type_name => "plevel",list => ["beginner","easy","medium","hard"]} + data_type: 'text' is_nullable: 0 =head2 name @@ -75,10 +77,14 @@ __PACKAGE__->table("problems"); =head2 runner - data_type: 'enum' - extra: {custom_type_name => "runner",list => ["File","Verifier","Interactive"]} + data_type: 'text' is_nullable: 0 +=head2 solution + + data_type: 'text' + is_nullable: 1 + =head2 statement data_type: 'text' @@ -102,6 +108,16 @@ __PACKAGE__->table("problems"); =head2 value data_type: 'integer' + is_nullable: 0 + +=head2 genformat + + data_type: 'text' + is_nullable: 1 + +=head2 gensource + + data_type: 'text' is_nullable: 1 =head2 verformat @@ -120,28 +136,15 @@ __PACKAGE__->add_columns( "id", { data_type => "text", is_nullable => 0 }, "author", - { data_type => "text", is_nullable => 0 }, + { data_type => "text", is_nullable => 1 }, + "writer", + { data_type => "text", is_nullable => 1 }, "generator", - { - data_type => "enum", - extra => { custom_type_name => "generator", list => ["File", "Run", "Undef"] }, - is_nullable => 0, - }, + { data_type => "text", is_nullable => 0 }, "judge", - { - data_type => "enum", - extra => { custom_type_name => "judge", list => ["Absolute", "Points"] }, - is_nullable => 0, - }, + { data_type => "text", is_nullable => 0 }, "level", - { - data_type => "enum", - extra => { - custom_type_name => "plevel", - list => ["beginner", "easy", "medium", "hard"], - }, - is_nullable => 0, - }, + { data_type => "text", is_nullable => 0 }, "name", { data_type => "text", is_nullable => 0 }, "olimit", @@ -151,14 +154,9 @@ __PACKAGE__->add_columns( "private", { data_type => "boolean", default_value => \"false", is_nullable => 0 }, "runner", - { - data_type => "enum", - extra => { - custom_type_name => "runner", - list => ["File", "Verifier", "Interactive"], - }, - is_nullable => 0, - }, + { data_type => "text", is_nullable => 0 }, + "solution", + { data_type => "text", is_nullable => 1 }, "statement", { data_type => "text", is_nullable => 0 }, "testcnt", @@ -168,7 +166,11 @@ __PACKAGE__->add_columns( "timeout", { data_type => "real", is_nullable => 0 }, "value", - { data_type => "integer", is_nullable => 1 }, + { data_type => "integer", is_nullable => 0 }, + "genformat", + { data_type => "text", is_nullable => 1 }, + "gensource", + { data_type => "text", is_nullable => 1 }, "verformat", { data_type => "text", is_nullable => 1 }, "versource", @@ -246,7 +248,22 @@ __PACKAGE__->belongs_to( "owner", "Gruntmaster::Data::Result::User", { id => "owner" }, - { is_deferrable => 0, on_delete => "NO ACTION", on_update => "NO ACTION" }, + { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" }, +); + +=head2 problem_statuses + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "problem_statuses", + "Gruntmaster::Data::Result::ProblemStatus", + { "foreign.problem" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, ); =head2 contests @@ -260,9 +277,53 @@ Composing rels: L -> contest __PACKAGE__->many_to_many("contests", "contest_problems", "contest"); -# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-03-24 09:25:07 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:dZicbasR8lUFGhIabrWxXw +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-12-11 23:51:27 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1SnNCeJdFr5lM3mmO6rtqA + +sub is_private { + my ($self, $time) = @_; + return 1 if $self->private; + grep { $_->contest->is_pending($time) } $self->contest_problems; +} +sub is_in_archive { + my ($self, $time) = @_; + 0 == grep { $_->contest->is_running($time) } $self->contest_problems; +} + +sub rerun { + $_->rerun for shift->jobs +} -# You can replace this text with custom code or comments, and it will be preserved on regeneration 1; + +__END__ + +=head1 METHODS + +=head2 is_private(I<[$time]>) + +Returns true if the problem is private at time I<$time> (which defaults to C