Add problem_status, contest_status and a method that updates them
[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
1980106a
MG
83=head2 solution
84
85 data_type: 'text'
86 is_nullable: 1
87
4ed3f8e7
MG
88=head2 statement
89
90 data_type: 'text'
91 is_nullable: 0
92
93=head2 testcnt
94
95 data_type: 'integer'
96 is_nullable: 0
97
b2725d9d
MG
98=head2 tests
99
100 data_type: 'text'
101 is_nullable: 1
102
4ed3f8e7
MG
103=head2 timeout
104
105 data_type: 'real'
106 is_nullable: 0
107
108=head2 value
109
110 data_type: 'integer'
aaa9eb7d 111 is_nullable: 0
4ed3f8e7 112
85d3f015
MG
113=head2 genformat
114
115 data_type: 'text'
116 is_nullable: 1
117
118=head2 gensource
119
120 data_type: 'text'
121 is_nullable: 1
122
4ed3f8e7
MG
123=head2 verformat
124
125 data_type: 'text'
126 is_nullable: 1
127
128=head2 versource
129
130 data_type: 'text'
131 is_nullable: 1
132
133=cut
134
135__PACKAGE__->add_columns(
136 "id",
137 { data_type => "text", is_nullable => 0 },
138 "author",
85d3f015 139 { data_type => "text", is_nullable => 1 },
6a03bf0d
MG
140 "writer",
141 { data_type => "text", is_nullable => 1 },
4ed3f8e7 142 "generator",
9bb39921 143 { data_type => "text", is_nullable => 0 },
4ed3f8e7 144 "judge",
9bb39921 145 { data_type => "text", is_nullable => 0 },
4ed3f8e7 146 "level",
9bb39921 147 { data_type => "text", is_nullable => 0 },
4ed3f8e7
MG
148 "name",
149 { data_type => "text", is_nullable => 0 },
150 "olimit",
151 { data_type => "integer", is_nullable => 1 },
152 "owner",
153 { data_type => "text", is_foreign_key => 1, is_nullable => 0 },
154 "private",
b2725d9d 155 { data_type => "boolean", default_value => \"false", is_nullable => 0 },
4ed3f8e7 156 "runner",
9bb39921 157 { data_type => "text", is_nullable => 0 },
1980106a
MG
158 "solution",
159 { data_type => "text", is_nullable => 1 },
4ed3f8e7
MG
160 "statement",
161 { data_type => "text", is_nullable => 0 },
162 "testcnt",
163 { data_type => "integer", is_nullable => 0 },
b2725d9d
MG
164 "tests",
165 { data_type => "text", is_nullable => 1 },
4ed3f8e7
MG
166 "timeout",
167 { data_type => "real", is_nullable => 0 },
168 "value",
aaa9eb7d 169 { data_type => "integer", is_nullable => 0 },
85d3f015
MG
170 "genformat",
171 { data_type => "text", is_nullable => 1 },
172 "gensource",
173 { data_type => "text", is_nullable => 1 },
4ed3f8e7
MG
174 "verformat",
175 { data_type => "text", is_nullable => 1 },
176 "versource",
177 { data_type => "text", is_nullable => 1 },
178);
179
180=head1 PRIMARY KEY
181
182=over 4
183
184=item * L</id>
185
186=back
187
188=cut
189
190__PACKAGE__->set_primary_key("id");
191
192=head1 RELATIONS
193
194=head2 contest_problems
195
196Type: has_many
197
198Related object: L<Gruntmaster::Data::Result::ContestProblem>
199
200=cut
201
202__PACKAGE__->has_many(
203 "contest_problems",
204 "Gruntmaster::Data::Result::ContestProblem",
205 { "foreign.problem" => "self.id" },
206 { cascade_copy => 0, cascade_delete => 0 },
207);
208
209=head2 jobs
210
211Type: has_many
212
213Related object: L<Gruntmaster::Data::Result::Job>
214
215=cut
216
217__PACKAGE__->has_many(
218 "jobs",
219 "Gruntmaster::Data::Result::Job",
220 { "foreign.problem" => "self.id" },
221 { cascade_copy => 0, cascade_delete => 0 },
222);
223
224=head2 opens
225
226Type: has_many
227
228Related object: L<Gruntmaster::Data::Result::Open>
229
230=cut
231
232__PACKAGE__->has_many(
233 "opens",
234 "Gruntmaster::Data::Result::Open",
235 { "foreign.problem" => "self.id" },
236 { cascade_copy => 0, cascade_delete => 0 },
237);
238
239=head2 owner
240
241Type: belongs_to
242
243Related object: L<Gruntmaster::Data::Result::User>
244
245=cut
246
247__PACKAGE__->belongs_to(
248 "owner",
249 "Gruntmaster::Data::Result::User",
250 { id => "owner" },
9bb39921 251 { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" },
4ed3f8e7
MG
252);
253
adb42d4d
MG
254=head2 problem_statuses
255
256Type: has_many
257
258Related object: L<Gruntmaster::Data::Result::ProblemStatus>
259
260=cut
261
262__PACKAGE__->has_many(
263 "problem_statuses",
264 "Gruntmaster::Data::Result::ProblemStatus",
265 { "foreign.problem" => "self.id" },
266 { cascade_copy => 0, cascade_delete => 0 },
267);
268
4ed3f8e7
MG
269=head2 contests
270
271Type: many_to_many
272
273Composing rels: L</contest_problems> -> contest
274
275=cut
276
277__PACKAGE__->many_to_many("contests", "contest_problems", "contest");
278
279
adb42d4d
MG
280# Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-12-11 23:51:27
281# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:1SnNCeJdFr5lM3mmO6rtqA
4ed3f8e7 282
4a8747ef
MG
283sub is_private {
284 my ($self, $time) = @_;
285 return 1 if $self->private;
286 grep { $_->contest->is_pending($time) } $self->contest_problems;
287}
288
289sub is_in_archive {
290 my ($self, $time) = @_;
291 0 == grep { $_->contest->is_running($time) } $self->contest_problems;
292}
293
294sub rerun {
295 $_->rerun for shift->jobs
296}
4ed3f8e7 297
4ed3f8e7 2981;
4a8747ef
MG
299
300__END__
301
302=head1 METHODS
303
304=head2 is_private(I<[$time]>)
305
306Returns true if the problem is private at time I<$time> (which defaults to C<time>).
307
308=head2 is_in_archive(I<[$time]>)
309
310Returns true if the problem is in the archive at time I<$time> (which defaults to C<time>).
311
312=head2 rerun
313
314Reruns all jobs for this problem.
315
316=head1 AUTHOR
317
318Marius Gavrilescu E<lt>marius@ieval.roE<gt>
319
320=head1 COPYRIGHT AND LICENSE
321
322Copyright (C) 2014 by Marius Gavrilescu
323
324This library is free software; you can redistribute it and/or modify
325it under the same terms as Perl itself, either Perl version 5.18.1 or,
326at your option, any later version of Perl 5 you may have available.
327
328
329=cut
This page took 0.029655 seconds and 4 git commands to generate.