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