From: Marius Gavrilescu Date: Mon, 16 Mar 2015 15:17:51 +0000 (+0200) Subject: Add limit overrides X-Git-Tag: 5999.000_014~56 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=6dda1f23dd233eaca23859432922dfdceb68358f;p=gruntmaster-data.git Add limit overrides --- diff --git a/db.sql b/db.sql index ba8a621..a9ea727 100644 --- a/db.sql +++ b/db.sql @@ -99,6 +99,13 @@ CREATE TABLE opens ( PRIMARY KEY (contest, problem, owner) ); +CREATE TABLE limits ( + problem TEXT NOT NULL REFERENCES problems ON DELETE CASCADE, + format TEXT NOT NULL, + timeout REAL NOT NULL, + PRIMARY KEY (problem, format) +); + CREATE TABLE table_comments ( table_name TEXT NOT NULL PRIMARY KEY, comment_text TEXT NOT NULL @@ -119,6 +126,7 @@ INSERT INTO table_comments VALUES ('contest_problems', 'Many-to-many bridge betw INSERT INTO table_comments VALUES ('jobs', 'List of jobs'); INSERT INTO table_comments VALUES ('problem_status', 'List of (problem, user, result)'); INSERT INTO table_comments VALUES ('opens', 'List of (contest, problem, user, time when user opened problem)'); +INSERT INTO table_comments VALUES ('limits', 'Time limit overrides for certain problem/format pairs'); INSERT INTO column_comments VALUES ('users', 'passphrase', 'RFC2307-encoded passphrase'); INSERT INTO column_comments VALUES ('users', 'name', 'Full name of user'); diff --git a/lib/Gruntmaster/Data.pm b/lib/Gruntmaster/Data.pm index e3b56f4..fa81e76 100644 --- a/lib/Gruntmaster/Data.pm +++ b/lib/Gruntmaster/Data.pm @@ -37,7 +37,7 @@ sub dynsub{ } BEGIN { - for my $rs (qw/contest contest_problem job open problem user problem_status contest_status/) { + for my $rs (qw/contest contest_problem job open limit problem user problem_status contest_status/) { my $rsname = ucfirst $rs; $rsname =~ s/_([a-z])/\u$1/gs; dynsub PL_N($rs) => sub { $_[0]->resultset($rsname) }; diff --git a/lib/Gruntmaster/Data/Result/Limit.pm b/lib/Gruntmaster/Data/Result/Limit.pm new file mode 100644 index 0000000..83b85e3 --- /dev/null +++ b/lib/Gruntmaster/Data/Result/Limit.pm @@ -0,0 +1,90 @@ +use utf8; +package Gruntmaster::Data::Result::Limit; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Gruntmaster::Data::Result::Limit - Time limit overrides for certain problem/format pairs + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("limits"); + +=head1 ACCESSORS + +=head2 problem + + data_type: 'text' + is_foreign_key: 1 + is_nullable: 0 + +=head2 format + + data_type: 'text' + is_nullable: 0 + +=head2 timeout + + data_type: 'real' + is_nullable: 0 + +=cut + +__PACKAGE__->add_columns( + "problem", + { data_type => "text", is_foreign_key => 1, is_nullable => 0 }, + "format", + { data_type => "text", is_nullable => 0 }, + "timeout", + { data_type => "real", is_nullable => 0 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("problem", "format"); + +=head1 RELATIONS + +=head2 problem + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "problem", + "Gruntmaster::Data::Result::Problem", + { id => "problem" }, + { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-03-16 17:16:58 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:ewngP+tVnk4GZ5K+ygUpLg + + +# You can replace this text with custom code or comments, and it will be preserved on regeneration +1; diff --git a/lib/Gruntmaster/Data/Result/Problem.pm b/lib/Gruntmaster/Data/Result/Problem.pm index cec4cc8..c067c76 100644 --- a/lib/Gruntmaster/Data/Result/Problem.pm +++ b/lib/Gruntmaster/Data/Result/Problem.pm @@ -264,6 +264,21 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 limits + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "limits", + "Gruntmaster::Data::Result::Limit", + { "foreign.problem" => "self.id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + =head2 opens Type: has_many @@ -320,8 +335,8 @@ Composing rels: L -> contest __PACKAGE__->many_to_many("contests", "contest_problems", "contest"); -# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-02-14 09:42:26 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:sc9vhXkFlp0UaLK7w0OUXA +# Created by DBIx::Class::Schema::Loader v0.07042 @ 2015-03-16 17:16:58 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:N7cuqDEGSn5rf8V5GovRQQ use Class::Method::Modifiers qw/after/;