]>
Commit | Line | Data |
---|---|---|
4ed3f8e7 MG |
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 | |
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' | |
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 | ||
196 | Type: has_many | |
197 | ||
198 | Related 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 | ||
211 | Type: has_many | |
212 | ||
213 | Related 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 | ||
226 | Type: has_many | |
227 | ||
228 | Related 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 | ||
241 | Type: belongs_to | |
242 | ||
243 | Related 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 | ||
254 | =head2 contests | |
255 | ||
256 | Type: many_to_many | |
257 | ||
258 | Composing rels: L</contest_problems> -> contest | |
259 | ||
260 | =cut | |
261 | ||
262 | __PACKAGE__->many_to_many("contests", "contest_problems", "contest"); | |
263 | ||
264 | ||
1980106a MG |
265 | # Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-12-07 00:51:56 |
266 | # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:KjAtOerTqBqtcMrBtwJ3Bw | |
4ed3f8e7 | 267 | |
4a8747ef MG |
268 | sub is_private { |
269 | my ($self, $time) = @_; | |
270 | return 1 if $self->private; | |
271 | grep { $_->contest->is_pending($time) } $self->contest_problems; | |
272 | } | |
273 | ||
274 | sub is_in_archive { | |
275 | my ($self, $time) = @_; | |
276 | 0 == grep { $_->contest->is_running($time) } $self->contest_problems; | |
277 | } | |
278 | ||
279 | sub rerun { | |
280 | $_->rerun for shift->jobs | |
281 | } | |
4ed3f8e7 | 282 | |
4ed3f8e7 | 283 | 1; |
4a8747ef MG |
284 | |
285 | __END__ | |
286 | ||
287 | =head1 METHODS | |
288 | ||
289 | =head2 is_private(I<[$time]>) | |
290 | ||
291 | Returns true if the problem is private at time I<$time> (which defaults to C<time>). | |
292 | ||
293 | =head2 is_in_archive(I<[$time]>) | |
294 | ||
295 | Returns true if the problem is in the archive at time I<$time> (which defaults to C<time>). | |
296 | ||
297 | =head2 rerun | |
298 | ||
299 | Reruns all jobs for this problem. | |
300 | ||
301 | =head1 AUTHOR | |
302 | ||
303 | Marius Gavrilescu E<lt>marius@ieval.roE<gt> | |
304 | ||
305 | =head1 COPYRIGHT AND LICENSE | |
306 | ||
307 | Copyright (C) 2014 by Marius Gavrilescu | |
308 | ||
309 | This library is free software; you can redistribute it and/or modify | |
310 | it under the same terms as Perl itself, either Perl version 5.18.1 or, | |
311 | at your option, any later version of Perl 5 you may have available. | |
312 | ||
313 | ||
314 | =cut |