Add table and column comments
[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
be2f7678 9Gruntmaster::Data::Result::Problem - List of problems
4ed3f8e7
MG
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
be2f7678
MG
36Full name(s) of problem author(s)/problemsetter(s)/tester(s)/etc
37
6a03bf0d
MG
38=head2 writer
39
40 data_type: 'text'
41 is_nullable: 1
42
be2f7678
MG
43Full name(s) of statement writer(s) (DEPRECATED)
44
4ed3f8e7
MG
45=head2 generator
46
9bb39921 47 data_type: 'text'
4ed3f8e7
MG
48 is_nullable: 0
49
be2f7678
MG
50Generator class, without the leading Gruntmaster::Daemon::Generator::
51
4ed3f8e7
MG
52=head2 judge
53
9bb39921 54 data_type: 'text'
4ed3f8e7
MG
55 is_nullable: 0
56
be2f7678
MG
57Judge class, without the leading Gruntmaster::Daemon::Judge::
58
4ed3f8e7
MG
59=head2 level
60
9bb39921 61 data_type: 'text'
4ed3f8e7
MG
62 is_nullable: 0
63
be2f7678
MG
64Problem level, one of beginner, easy, medium, hard
65
4ed3f8e7
MG
66=head2 name
67
68 data_type: 'text'
69 is_nullable: 0
70
71=head2 olimit
72
73 data_type: 'integer'
74 is_nullable: 1
75
be2f7678
MG
76Output limit (in bytes)
77
4ed3f8e7
MG
78=head2 owner
79
80 data_type: 'text'
81 is_foreign_key: 1
82 is_nullable: 0
83
84=head2 private
85
86 data_type: 'boolean'
b2725d9d 87 default_value: false
4ed3f8e7
MG
88 is_nullable: 0
89
90=head2 runner
91
9bb39921 92 data_type: 'text'
4ed3f8e7
MG
93 is_nullable: 0
94
be2f7678
MG
95Runner class, without the leading Gruntmaster::Daemon::Runner::
96
1980106a
MG
97=head2 solution
98
99 data_type: 'text'
100 is_nullable: 1
101
be2f7678
MG
102Solution (HTML)
103
4ed3f8e7
MG
104=head2 statement
105
106 data_type: 'text'
107 is_nullable: 0
108
be2f7678
MG
109Statement (HTML)
110
4ed3f8e7
MG
111=head2 testcnt
112
113 data_type: 'integer'
114 is_nullable: 0
115
be2f7678
MG
116Number of tests
117
b2725d9d
MG
118=head2 tests
119
120 data_type: 'text'
121 is_nullable: 1
122
be2f7678
MG
123JSON array of test values for ::Runner::File
124
4ed3f8e7
MG
125=head2 timeout
126
127 data_type: 'real'
128 is_nullable: 0
129
be2f7678
MG
130Time limit (in seconds)
131
4ed3f8e7
MG
132=head2 value
133
134 data_type: 'integer'
aaa9eb7d 135 is_nullable: 0
4ed3f8e7 136
be2f7678
MG
137Problem value when used in a contest.
138
85d3f015
MG
139=head2 genformat
140
141 data_type: 'text'
142 is_nullable: 1
143
be2f7678
MG
144Format (programming language) of the generator if using the Run generator
145
85d3f015
MG
146=head2 gensource
147
148 data_type: 'text'
149 is_nullable: 1
150
be2f7678
MG
151Source code of generator if using the Run generator
152
4ed3f8e7
MG
153=head2 verformat
154
155 data_type: 'text'
156 is_nullable: 1
157
be2f7678
MG
158Format (programming language) of the verifier if using the Verifier runner
159
4ed3f8e7
MG
160=head2 versource
161
162 data_type: 'text'
163 is_nullable: 1
164
be2f7678
MG
165Source code of verifier if using the Verifier runner
166
4ed3f8e7
MG
167=cut
168
169__PACKAGE__->add_columns(
170 "id",
171 { data_type => "text", is_nullable => 0 },
172 "author",
85d3f015 173 { data_type => "text", is_nullable => 1 },
6a03bf0d
MG
174 "writer",
175 { data_type => "text", is_nullable => 1 },
4ed3f8e7 176 "generator",
9bb39921 177 { data_type => "text", is_nullable => 0 },
4ed3f8e7 178 "judge",
9bb39921 179 { data_type => "text", is_nullable => 0 },
4ed3f8e7 180 "level",
9bb39921 181 { data_type => "text", is_nullable => 0 },
4ed3f8e7
MG
182 "name",
183 { data_type => "text", is_nullable => 0 },
184 "olimit",
185 { data_type => "integer", is_nullable => 1 },
186 "owner",
187 { data_type => "text", is_foreign_key => 1, is_nullable => 0 },
188 "private",
b2725d9d 189 { data_type => "boolean", default_value => \"false", is_nullable => 0 },
4ed3f8e7 190 "runner",
9bb39921 191 { data_type => "text", is_nullable => 0 },
1980106a
MG
192 "solution",
193 { data_type => "text", is_nullable => 1 },
4ed3f8e7
MG
194 "statement",
195 { data_type => "text", is_nullable => 0 },
196 "testcnt",
197 { data_type => "integer", is_nullable => 0 },
b2725d9d
MG
198 "tests",
199 { data_type => "text", is_nullable => 1 },
4ed3f8e7
MG
200 "timeout",
201 { data_type => "real", is_nullable => 0 },
202 "value",
aaa9eb7d 203 { data_type => "integer", is_nullable => 0 },
85d3f015
MG
204 "genformat",
205 { data_type => "text", is_nullable => 1 },
206 "gensource",
207 { data_type => "text", is_nullable => 1 },
4ed3f8e7
MG
208 "verformat",
209 { data_type => "text", is_nullable => 1 },
210 "versource",
211 { data_type => "text", is_nullable => 1 },
212);
213
214=head1 PRIMARY KEY
215
216=over 4
217
218=item * L</id>
219
220=back
221
222=cut
223
224__PACKAGE__->set_primary_key("id");
225
226=head1 RELATIONS
227
228=head2 contest_problems
229
230Type: has_many
231
232Related object: L<Gruntmaster::Data::Result::ContestProblem>
233
234=cut
235
236__PACKAGE__->has_many(
237 "contest_problems",
238 "Gruntmaster::Data::Result::ContestProblem",
239 { "foreign.problem" => "self.id" },
240 { cascade_copy => 0, cascade_delete => 0 },
241);
242
243=head2 jobs
244
245Type: has_many
246
247Related object: L<Gruntmaster::Data::Result::Job>
248
249=cut
250
251__PACKAGE__->has_many(
252 "jobs",
253 "Gruntmaster::Data::Result::Job",
254 { "foreign.problem" => "self.id" },
255 { cascade_copy => 0, cascade_delete => 0 },
256);
257
258=head2 opens
259
260Type: has_many
261
262Related object: L<Gruntmaster::Data::Result::Open>
263
264=cut
265
266__PACKAGE__->has_many(
267 "opens",
268 "Gruntmaster::Data::Result::Open",
269 { "foreign.problem" => "self.id" },
270 { cascade_copy => 0, cascade_delete => 0 },
271);
272
273=head2 owner
274
275Type: belongs_to
276
277Related object: L<Gruntmaster::Data::Result::User>
278
279=cut
280
281__PACKAGE__->belongs_to(
282 "owner",
283 "Gruntmaster::Data::Result::User",
284 { id => "owner" },
9bb39921 285 { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
4ed3f8e7
MG
286);
287
adb42d4d
MG
288=head2 problem_statuses
289
290Type: has_many
291
292Related object: L<Gruntmaster::Data::Result::ProblemStatus>
293
294=cut
295
296__PACKAGE__->has_many(
297 "problem_statuses",
298 "Gruntmaster::Data::Result::ProblemStatus",
299 { "foreign.problem" => "self.id" },
300 { cascade_copy => 0, cascade_delete => 0 },
301);
302
4ed3f8e7
MG
303=head2 contests
304
305Type: many_to_many
306
307Composing rels: L</contest_problems> -> contest
308
309=cut
310
311__PACKAGE__->many_to_many("contests", "contest_problems", "contest");
312
313
be2f7678
MG
314# Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-12-19 16:54:00
315# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:QZHyWOWaPmTm/EQ5M22CGA
4ed3f8e7 316
4a8747ef
MG
317sub is_private {
318 my ($self, $time) = @_;
319 return 1 if $self->private;
320 grep { $_->contest->is_pending($time) } $self->contest_problems;
321}
322
323sub is_in_archive {
324 my ($self, $time) = @_;
325 0 == grep { $_->contest->is_running($time) } $self->contest_problems;
326}
327
328sub rerun {
329 $_->rerun for shift->jobs
330}
4ed3f8e7 331
4ed3f8e7 3321;
4a8747ef
MG
333
334__END__
335
336=head1 METHODS
337
338=head2 is_private(I<[$time]>)
339
340Returns true if the problem is private at time I<$time> (which defaults to C<time>).
341
342=head2 is_in_archive(I<[$time]>)
343
344Returns true if the problem is in the archive at time I<$time> (which defaults to C<time>).
345
346=head2 rerun
347
348Reruns all jobs for this problem.
349
350=head1 AUTHOR
351
352Marius Gavrilescu E<lt>marius@ieval.roE<gt>
353
354=head1 COPYRIGHT AND LICENSE
355
356Copyright (C) 2014 by Marius Gavrilescu
357
358This library is free software; you can redistribute it and/or modify
359it under the same terms as Perl itself, either Perl version 5.18.1 or,
360at your option, any later version of Perl 5 you may have available.
361
362
363=cut
This page took 0.032875 seconds and 4 git commands to generate.