]>
Commit | Line | Data |
---|---|---|
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 | use Class::Method::Modifiers qw/after/; | |
318 | ||
319 | after qw/insert update delete/ => sub { | |
320 | my ($self) = @_; | |
321 | Gruntmaster::Data::purge '/pb/'; | |
322 | Gruntmaster::Data::purge '/pb/' . $self->id; | |
323 | Gruntmaster::Data::purge '/csol/' . $self->id; | |
324 | }; | |
325 | ||
326 | sub is_private { | |
327 | my ($self, $time) = @_; | |
328 | return 0 if grep { !$_->contest->is_pending($time) } $self->contest_problems; | |
329 | return 1 if $self->private; | |
330 | grep { $_->contest->is_pending($time) } $self->contest_problems; | |
331 | } | |
332 | ||
333 | sub is_in_archive { | |
334 | my ($self, $time) = @_; | |
335 | 0 == grep { $_->contest->is_running($time) } $self->contest_problems; | |
336 | } | |
337 | ||
338 | sub rerun { | |
339 | $_->rerun for shift->jobs | |
340 | } | |
341 | ||
342 | 1; | |
343 | ||
344 | __END__ | |
345 | ||
346 | =head1 METHODS | |
347 | ||
348 | =head2 is_private(I<[$time]>) | |
349 | ||
350 | Returns true if the problem is private at time I<$time> (which defaults to C<time>). | |
351 | ||
352 | =head2 is_in_archive(I<[$time]>) | |
353 | ||
354 | Returns true if the problem is in the archive at time I<$time> (which defaults to C<time>). | |
355 | ||
356 | =head2 rerun | |
357 | ||
358 | Reruns all jobs for this problem. | |
359 | ||
360 | =head1 AUTHOR | |
361 | ||
362 | Marius Gavrilescu E<lt>marius@ieval.roE<gt> | |
363 | ||
364 | =head1 COPYRIGHT AND LICENSE | |
365 | ||
366 | Copyright (C) 2014 by Marius Gavrilescu | |
367 | ||
368 | This library is free software; you can redistribute it and/or modify | |
369 | it under the same terms as Perl itself, either Perl version 5.18.1 or, | |
370 | at your option, any later version of Perl 5 you may have available. | |
371 | ||
372 | ||
373 | =cut |