Use ON DELETE CASCADE and TEXT instead of enums
[gruntmaster-data.git] / lib / Gruntmaster / Data / Result / Problem.pm
CommitLineData
4ed3f8e7
MG
1use utf8;
2package Gruntmaster::Data::Result::Problem;
3
4# Created by DBIx::Class::Schema::Loader
5# DO NOT MODIFY THE FIRST PART OF THIS FILE
6
7=head1 NAME
8
9Gruntmaster::Data::Result::Problem
10
11=cut
12
13use strict;
14use warnings;
15
16use base 'DBIx::Class::Core';
17
18=head1 TABLE: C<problems>
19
20=cut
21
22__PACKAGE__->table("problems");
23
24=head1 ACCESSORS
25
26=head2 id
27
28 data_type: 'text'
29 is_nullable: 0
30
31=head2 author
32
33 data_type: 'text'
85d3f015 34 is_nullable: 1
4ed3f8e7 35
6a03bf0d
MG
36=head2 writer
37
38 data_type: 'text'
39 is_nullable: 1
40
4ed3f8e7
MG
41=head2 generator
42
9bb39921 43 data_type: 'text'
4ed3f8e7
MG
44 is_nullable: 0
45
46=head2 judge
47
9bb39921 48 data_type: 'text'
4ed3f8e7
MG
49 is_nullable: 0
50
51=head2 level
52
9bb39921 53 data_type: 'text'
4ed3f8e7
MG
54 is_nullable: 0
55
56=head2 name
57
58 data_type: 'text'
59 is_nullable: 0
60
61=head2 olimit
62
63 data_type: 'integer'
64 is_nullable: 1
65
66=head2 owner
67
68 data_type: 'text'
69 is_foreign_key: 1
70 is_nullable: 0
71
72=head2 private
73
74 data_type: 'boolean'
b2725d9d 75 default_value: false
4ed3f8e7
MG
76 is_nullable: 0
77
78=head2 runner
79
9bb39921 80 data_type: 'text'
4ed3f8e7
MG
81 is_nullable: 0
82
83=head2 statement
84
85 data_type: 'text'
86 is_nullable: 0
87
88=head2 testcnt
89
90 data_type: 'integer'
91 is_nullable: 0
92
b2725d9d
MG
93=head2 tests
94
95 data_type: 'text'
96 is_nullable: 1
97
4ed3f8e7
MG
98=head2 timeout
99
100 data_type: 'real'
101 is_nullable: 0
102
103=head2 value
104
105 data_type: 'integer'
106 is_nullable: 1
107
85d3f015
MG
108=head2 genformat
109
110 data_type: 'text'
111 is_nullable: 1
112
113=head2 gensource
114
115 data_type: 'text'
116 is_nullable: 1
117
4ed3f8e7
MG
118=head2 verformat
119
120 data_type: 'text'
121 is_nullable: 1
122
123=head2 versource
124
125 data_type: 'text'
126 is_nullable: 1
127
128=cut
129
130__PACKAGE__->add_columns(
131 "id",
132 { data_type => "text", is_nullable => 0 },
133 "author",
85d3f015 134 { data_type => "text", is_nullable => 1 },
6a03bf0d
MG
135 "writer",
136 { data_type => "text", is_nullable => 1 },
4ed3f8e7 137 "generator",
9bb39921 138 { data_type => "text", is_nullable => 0 },
4ed3f8e7 139 "judge",
9bb39921 140 { data_type => "text", is_nullable => 0 },
4ed3f8e7 141 "level",
9bb39921 142 { data_type => "text", is_nullable => 0 },
4ed3f8e7
MG
143 "name",
144 { data_type => "text", is_nullable => 0 },
145 "olimit",
146 { data_type => "integer", is_nullable => 1 },
147 "owner",
148 { data_type => "text", is_foreign_key => 1, is_nullable => 0 },
149 "private",
b2725d9d 150 { data_type => "boolean", default_value => \"false", is_nullable => 0 },
4ed3f8e7 151 "runner",
9bb39921 152 { data_type => "text", is_nullable => 0 },
4ed3f8e7
MG
153 "statement",
154 { data_type => "text", is_nullable => 0 },
155 "testcnt",
156 { data_type => "integer", is_nullable => 0 },
b2725d9d
MG
157 "tests",
158 { data_type => "text", is_nullable => 1 },
4ed3f8e7
MG
159 "timeout",
160 { data_type => "real", is_nullable => 0 },
161 "value",
162 { data_type => "integer", is_nullable => 1 },
85d3f015
MG
163 "genformat",
164 { data_type => "text", is_nullable => 1 },
165 "gensource",
166 { data_type => "text", is_nullable => 1 },
4ed3f8e7
MG
167 "verformat",
168 { data_type => "text", is_nullable => 1 },
169 "versource",
170 { data_type => "text", is_nullable => 1 },
171);
172
173=head1 PRIMARY KEY
174
175=over 4
176
177=item * L</id>
178
179=back
180
181=cut
182
183__PACKAGE__->set_primary_key("id");
184
185=head1 RELATIONS
186
187=head2 contest_problems
188
189Type: has_many
190
191Related object: L<Gruntmaster::Data::Result::ContestProblem>
192
193=cut
194
195__PACKAGE__->has_many(
196 "contest_problems",
197 "Gruntmaster::Data::Result::ContestProblem",
198 { "foreign.problem" => "self.id" },
199 { cascade_copy => 0, cascade_delete => 0 },
200);
201
202=head2 jobs
203
204Type: has_many
205
206Related object: L<Gruntmaster::Data::Result::Job>
207
208=cut
209
210__PACKAGE__->has_many(
211 "jobs",
212 "Gruntmaster::Data::Result::Job",
213 { "foreign.problem" => "self.id" },
214 { cascade_copy => 0, cascade_delete => 0 },
215);
216
217=head2 opens
218
219Type: has_many
220
221Related object: L<Gruntmaster::Data::Result::Open>
222
223=cut
224
225__PACKAGE__->has_many(
226 "opens",
227 "Gruntmaster::Data::Result::Open",
228 { "foreign.problem" => "self.id" },
229 { cascade_copy => 0, cascade_delete => 0 },
230);
231
232=head2 owner
233
234Type: belongs_to
235
236Related object: L<Gruntmaster::Data::Result::User>
237
238=cut
239
240__PACKAGE__->belongs_to(
241 "owner",
242 "Gruntmaster::Data::Result::User",
243 { id => "owner" },
9bb39921 244 { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
4ed3f8e7
MG
245);
246
247=head2 contests
248
249Type: many_to_many
250
251Composing rels: L</contest_problems> -> contest
252
253=cut
254
255__PACKAGE__->many_to_many("contests", "contest_problems", "contest");
256
257
9bb39921
MG
258# Created by DBIx::Class::Schema::Loader v0.07039 @ 2014-05-16 15:03:32
259# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:tvap77v0faSMxFiLu1uggQ
4ed3f8e7 260
4a8747ef
MG
261sub is_private {
262 my ($self, $time) = @_;
263 return 1 if $self->private;
264 grep { $_->contest->is_pending($time) } $self->contest_problems;
265}
266
267sub is_in_archive {
268 my ($self, $time) = @_;
269 0 == grep { $_->contest->is_running($time) } $self->contest_problems;
270}
271
272sub rerun {
273 $_->rerun for shift->jobs
274}
4ed3f8e7 275
4ed3f8e7 2761;
4a8747ef
MG
277
278__END__
279
280=head1 METHODS
281
282=head2 is_private(I<[$time]>)
283
284Returns true if the problem is private at time I<$time> (which defaults to C<time>).
285
286=head2 is_in_archive(I<[$time]>)
287
288Returns true if the problem is in the archive at time I<$time> (which defaults to C<time>).
289
290=head2 rerun
291
292Reruns all jobs for this problem.
293
294=head1 AUTHOR
295
296Marius Gavrilescu E<lt>marius@ieval.roE<gt>
297
298=head1 COPYRIGHT AND LICENSE
299
300Copyright (C) 2014 by Marius Gavrilescu
301
302This library is free software; you can redistribute it and/or modify
303it under the same terms as Perl itself, either Perl version 5.18.1 or,
304at your option, any later version of Perl 5 you may have available.
305
306
307=cut
This page took 0.028925 seconds and 4 git commands to generate.