Add table and column comments
[gruntmaster-data.git] / lib / Gruntmaster / Data / Result / Problem.pm
1 use utf8;
2 package 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
9 Gruntmaster::Data::Result::Problem - List of problems
10
11 =cut
12
13 use strict;
14 use warnings;
15
16 use 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'
34 is_nullable: 1
35
36 Full name(s) of problem author(s)/problemsetter(s)/tester(s)/etc
37
38 =head2 writer
39
40 data_type: 'text'
41 is_nullable: 1
42
43 Full name(s) of statement writer(s) (DEPRECATED)
44
45 =head2 generator
46
47 data_type: 'text'
48 is_nullable: 0
49
50 Generator class, without the leading Gruntmaster::Daemon::Generator::
51
52 =head2 judge
53
54 data_type: 'text'
55 is_nullable: 0
56
57 Judge class, without the leading Gruntmaster::Daemon::Judge::
58
59 =head2 level
60
61 data_type: 'text'
62 is_nullable: 0
63
64 Problem level, one of beginner, easy, medium, hard
65
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
76 Output limit (in bytes)
77
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'
87 default_value: false
88 is_nullable: 0
89
90 =head2 runner
91
92 data_type: 'text'
93 is_nullable: 0
94
95 Runner class, without the leading Gruntmaster::Daemon::Runner::
96
97 =head2 solution
98
99 data_type: 'text'
100 is_nullable: 1
101
102 Solution (HTML)
103
104 =head2 statement
105
106 data_type: 'text'
107 is_nullable: 0
108
109 Statement (HTML)
110
111 =head2 testcnt
112
113 data_type: 'integer'
114 is_nullable: 0
115
116 Number of tests
117
118 =head2 tests
119
120 data_type: 'text'
121 is_nullable: 1
122
123 JSON array of test values for ::Runner::File
124
125 =head2 timeout
126
127 data_type: 'real'
128 is_nullable: 0
129
130 Time limit (in seconds)
131
132 =head2 value
133
134 data_type: 'integer'
135 is_nullable: 0
136
137 Problem value when used in a contest.
138
139 =head2 genformat
140
141 data_type: 'text'
142 is_nullable: 1
143
144 Format (programming language) of the generator if using the Run generator
145
146 =head2 gensource
147
148 data_type: 'text'
149 is_nullable: 1
150
151 Source code of generator if using the Run generator
152
153 =head2 verformat
154
155 data_type: 'text'
156 is_nullable: 1
157
158 Format (programming language) of the verifier if using the Verifier runner
159
160 =head2 versource
161
162 data_type: 'text'
163 is_nullable: 1
164
165 Source code of verifier if using the Verifier runner
166
167 =cut
168
169 __PACKAGE__->add_columns(
170 "id",
171 { data_type => "text", is_nullable => 0 },
172 "author",
173 { data_type => "text", is_nullable => 1 },
174 "writer",
175 { data_type => "text", is_nullable => 1 },
176 "generator",
177 { data_type => "text", is_nullable => 0 },
178 "judge",
179 { data_type => "text", is_nullable => 0 },
180 "level",
181 { data_type => "text", is_nullable => 0 },
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",
189 { data_type => "boolean", default_value => \"false", is_nullable => 0 },
190 "runner",
191 { data_type => "text", is_nullable => 0 },
192 "solution",
193 { data_type => "text", is_nullable => 1 },
194 "statement",
195 { data_type => "text", is_nullable => 0 },
196 "testcnt",
197 { data_type => "integer", is_nullable => 0 },
198 "tests",
199 { data_type => "text", is_nullable => 1 },
200 "timeout",
201 { data_type => "real", is_nullable => 0 },
202 "value",
203 { data_type => "integer", is_nullable => 0 },
204 "genformat",
205 { data_type => "text", is_nullable => 1 },
206 "gensource",
207 { data_type => "text", is_nullable => 1 },
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
230 Type: has_many
231
232 Related 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
245 Type: has_many
246
247 Related 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
260 Type: has_many
261
262 Related 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
275 Type: belongs_to
276
277 Related object: L<Gruntmaster::Data::Result::User>
278
279 =cut
280
281 __PACKAGE__->belongs_to(
282 "owner",
283 "Gruntmaster::Data::Result::User",
284 { id => "owner" },
285 { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
286 );
287
288 =head2 problem_statuses
289
290 Type: has_many
291
292 Related 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
303 =head2 contests
304
305 Type: many_to_many
306
307 Composing rels: L</contest_problems> -> contest
308
309 =cut
310
311 __PACKAGE__->many_to_many("contests", "contest_problems", "contest");
312
313
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
316
317 sub is_private {
318 my ($self, $time) = @_;
319 return 1 if $self->private;
320 grep { $_->contest->is_pending($time) } $self->contest_problems;
321 }
322
323 sub is_in_archive {
324 my ($self, $time) = @_;
325 0 == grep { $_->contest->is_running($time) } $self->contest_problems;
326 }
327
328 sub rerun {
329 $_->rerun for shift->jobs
330 }
331
332 1;
333
334 __END__
335
336 =head1 METHODS
337
338 =head2 is_private(I<[$time]>)
339
340 Returns true if the problem is private at time I<$time> (which defaults to C<time>).
341
342 =head2 is_in_archive(I<[$time]>)
343
344 Returns true if the problem is in the archive at time I<$time> (which defaults to C<time>).
345
346 =head2 rerun
347
348 Reruns all jobs for this problem.
349
350 =head1 AUTHOR
351
352 Marius Gavrilescu E<lt>marius@ieval.roE<gt>
353
354 =head1 COPYRIGHT AND LICENSE
355
356 Copyright (C) 2014 by Marius Gavrilescu
357
358 This library is free software; you can redistribute it and/or modify
359 it under the same terms as Perl itself, either Perl version 5.18.1 or,
360 at your option, any later version of Perl 5 you may have available.
361
362
363 =cut
This page took 0.03556 seconds and 4 git commands to generate.