]> iEval git - gruntmaster-data.git/blame_incremental - lib/Gruntmaster/Data/Result/Problem.pm
Purge affected pages on insert/update/delete
[gruntmaster-data.git] / lib / Gruntmaster / Data / Result / Problem.pm
... / ...
CommitLineData
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 - List of problems
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'
34 is_nullable: 1
35
36Full 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
43Full name(s) of statement writer(s) (DEPRECATED)
44
45=head2 generator
46
47 data_type: 'text'
48 is_nullable: 0
49
50Generator class, without the leading Gruntmaster::Daemon::Generator::
51
52=head2 judge
53
54 data_type: 'text'
55 is_nullable: 0
56
57Judge class, without the leading Gruntmaster::Daemon::Judge::
58
59=head2 level
60
61 data_type: 'text'
62 is_nullable: 0
63
64Problem 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
76Output 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
95Runner class, without the leading Gruntmaster::Daemon::Runner::
96
97=head2 solution
98
99 data_type: 'text'
100 is_nullable: 1
101
102Solution (HTML)
103
104=head2 statement
105
106 data_type: 'text'
107 is_nullable: 0
108
109Statement (HTML)
110
111=head2 testcnt
112
113 data_type: 'integer'
114 is_nullable: 0
115
116Number of tests
117
118=head2 tests
119
120 data_type: 'text'
121 is_nullable: 1
122
123JSON array of test values for ::Runner::File
124
125=head2 timeout
126
127 data_type: 'real'
128 is_nullable: 0
129
130Time limit (in seconds)
131
132=head2 value
133
134 data_type: 'integer'
135 is_nullable: 0
136
137Problem value when used in a contest.
138
139=head2 genformat
140
141 data_type: 'text'
142 is_nullable: 1
143
144Format (programming language) of the generator if using the Run generator
145
146=head2 gensource
147
148 data_type: 'text'
149 is_nullable: 1
150
151Source code of generator if using the Run generator
152
153=head2 verformat
154
155 data_type: 'text'
156 is_nullable: 1
157
158Format (programming language) of the verifier if using the Verifier runner
159
160=head2 versource
161
162 data_type: 'text'
163 is_nullable: 1
164
165Source 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
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" },
285 { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
286);
287
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
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
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
317use Class::Method::Modifiers qw/after/;
318
319after qw/insert update delete/ => sub {
320 my ($self) = @_;
321 Gruntmaster::Data::purge '/pb/';
322 Gruntmaster::Data::purge '/pb/' . $self->id;
323};
324
325sub is_private {
326 my ($self, $time) = @_;
327 return 1 if $self->private;
328 grep { $_->contest->is_pending($time) } $self->contest_problems;
329}
330
331sub is_in_archive {
332 my ($self, $time) = @_;
333 0 == grep { $_->contest->is_running($time) } $self->contest_problems;
334}
335
336sub rerun {
337 $_->rerun for shift->jobs
338}
339
3401;
341
342__END__
343
344=head1 METHODS
345
346=head2 is_private(I<[$time]>)
347
348Returns true if the problem is private at time I<$time> (which defaults to C<time>).
349
350=head2 is_in_archive(I<[$time]>)
351
352Returns true if the problem is in the archive at time I<$time> (which defaults to C<time>).
353
354=head2 rerun
355
356Reruns all jobs for this problem.
357
358=head1 AUTHOR
359
360Marius Gavrilescu E<lt>marius@ieval.roE<gt>
361
362=head1 COPYRIGHT AND LICENSE
363
364Copyright (C) 2014 by Marius Gavrilescu
365
366This library is free software; you can redistribute it and/or modify
367it under the same terms as Perl itself, either Perl version 5.18.1 or,
368at your option, any later version of Perl 5 you may have available.
369
370
371=cut
This page took 0.026208 seconds and 4 git commands to generate.