]>
Commit | Line | Data |
---|---|---|
1 | use utf8; | |
2 | package Gruntmaster::Data::Result::Job; | |
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::Job - List of jobs | |
10 | ||
11 | =cut | |
12 | ||
13 | use strict; | |
14 | use warnings; | |
15 | ||
16 | use base 'DBIx::Class::Core'; | |
17 | ||
18 | =head1 TABLE: C<jobs> | |
19 | ||
20 | =cut | |
21 | ||
22 | __PACKAGE__->table("jobs"); | |
23 | ||
24 | =head1 ACCESSORS | |
25 | ||
26 | =head2 id | |
27 | ||
28 | data_type: 'integer' | |
29 | is_auto_increment: 1 | |
30 | is_nullable: 0 | |
31 | sequence: 'jobs_id_seq' | |
32 | ||
33 | =head2 contest | |
34 | ||
35 | data_type: 'text' | |
36 | is_foreign_key: 1 | |
37 | is_nullable: 1 | |
38 | ||
39 | =head2 daemon | |
40 | ||
41 | data_type: 'text' | |
42 | is_nullable: 1 | |
43 | ||
44 | hostname:PID of daemon that last executed this job. NULL if never executed | |
45 | ||
46 | =head2 date | |
47 | ||
48 | data_type: 'bigint' | |
49 | is_nullable: 0 | |
50 | ||
51 | Unix time when job was submitted | |
52 | ||
53 | =head2 errors | |
54 | ||
55 | data_type: 'text' | |
56 | is_nullable: 1 | |
57 | ||
58 | Compiler errors | |
59 | ||
60 | =head2 extension | |
61 | ||
62 | data_type: 'text' | |
63 | is_nullable: 0 | |
64 | ||
65 | File extension of submitted program, without a leading dot | |
66 | ||
67 | =head2 format | |
68 | ||
69 | data_type: 'text' | |
70 | is_nullable: 0 | |
71 | ||
72 | Format (programming language) of submitted program | |
73 | ||
74 | =head2 private | |
75 | ||
76 | data_type: 'boolean' | |
77 | default_value: false | |
78 | is_nullable: 0 | |
79 | ||
80 | =head2 problem | |
81 | ||
82 | data_type: 'text' | |
83 | is_foreign_key: 1 | |
84 | is_nullable: 0 | |
85 | ||
86 | =head2 result | |
87 | ||
88 | data_type: 'integer' | |
89 | is_nullable: 1 | |
90 | ||
91 | Job result (integer constant from Gruntmaster::Daemon::Constants) | |
92 | ||
93 | =head2 result_text | |
94 | ||
95 | data_type: 'text' | |
96 | is_nullable: 1 | |
97 | ||
98 | Job result (human-readable text) | |
99 | ||
100 | =head2 results | |
101 | ||
102 | data_type: 'text' | |
103 | is_nullable: 1 | |
104 | ||
105 | Per-test results (JSON array of hashes with keys id (test number, counting from 1), result (integer constant from Gruntmaster::Daemon::Constants), result_text (human-readable text), time (execution time in decimal seconds)) | |
106 | ||
107 | =head2 source | |
108 | ||
109 | data_type: 'text' | |
110 | is_nullable: 0 | |
111 | ||
112 | =head2 owner | |
113 | ||
114 | data_type: 'text' | |
115 | is_foreign_key: 1 | |
116 | is_nullable: 0 | |
117 | ||
118 | =cut | |
119 | ||
120 | __PACKAGE__->add_columns( | |
121 | "id", | |
122 | { | |
123 | data_type => "integer", | |
124 | is_auto_increment => 1, | |
125 | is_nullable => 0, | |
126 | sequence => "jobs_id_seq", | |
127 | }, | |
128 | "contest", | |
129 | { data_type => "text", is_foreign_key => 1, is_nullable => 1 }, | |
130 | "daemon", | |
131 | { data_type => "text", is_nullable => 1 }, | |
132 | "date", | |
133 | { data_type => "bigint", is_nullable => 0 }, | |
134 | "errors", | |
135 | { data_type => "text", is_nullable => 1 }, | |
136 | "extension", | |
137 | { data_type => "text", is_nullable => 0 }, | |
138 | "format", | |
139 | { data_type => "text", is_nullable => 0 }, | |
140 | "private", | |
141 | { data_type => "boolean", default_value => \"false", is_nullable => 0 }, | |
142 | "problem", | |
143 | { data_type => "text", is_foreign_key => 1, is_nullable => 0 }, | |
144 | "result", | |
145 | { data_type => "integer", is_nullable => 1 }, | |
146 | "result_text", | |
147 | { data_type => "text", is_nullable => 1 }, | |
148 | "results", | |
149 | { data_type => "text", is_nullable => 1 }, | |
150 | "source", | |
151 | { data_type => "text", is_nullable => 0 }, | |
152 | "owner", | |
153 | { data_type => "text", is_foreign_key => 1, is_nullable => 0 }, | |
154 | ); | |
155 | ||
156 | =head1 PRIMARY KEY | |
157 | ||
158 | =over 4 | |
159 | ||
160 | =item * L</id> | |
161 | ||
162 | =back | |
163 | ||
164 | =cut | |
165 | ||
166 | __PACKAGE__->set_primary_key("id"); | |
167 | ||
168 | =head1 RELATIONS | |
169 | ||
170 | =head2 contest | |
171 | ||
172 | Type: belongs_to | |
173 | ||
174 | Related object: L<Gruntmaster::Data::Result::Contest> | |
175 | ||
176 | =cut | |
177 | ||
178 | __PACKAGE__->belongs_to( | |
179 | "contest", | |
180 | "Gruntmaster::Data::Result::Contest", | |
181 | { id => "contest" }, | |
182 | { | |
183 | is_deferrable => 0, | |
184 | join_type => "LEFT", | |
185 | on_delete => "CASCADE", | |
186 | on_update => "NO ACTION", | |
187 | }, | |
188 | ); | |
189 | ||
190 | =head2 owner | |
191 | ||
192 | Type: belongs_to | |
193 | ||
194 | Related object: L<Gruntmaster::Data::Result::User> | |
195 | ||
196 | =cut | |
197 | ||
198 | __PACKAGE__->belongs_to( | |
199 | "owner", | |
200 | "Gruntmaster::Data::Result::User", | |
201 | { id => "owner" }, | |
202 | { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" }, | |
203 | ); | |
204 | ||
205 | =head2 problem | |
206 | ||
207 | Type: belongs_to | |
208 | ||
209 | Related object: L<Gruntmaster::Data::Result::Problem> | |
210 | ||
211 | =cut | |
212 | ||
213 | __PACKAGE__->belongs_to( | |
214 | "problem", | |
215 | "Gruntmaster::Data::Result::Problem", | |
216 | { id => "problem" }, | |
217 | { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" }, | |
218 | ); | |
219 | ||
220 | =head2 problem_statuses | |
221 | ||
222 | Type: has_many | |
223 | ||
224 | Related object: L<Gruntmaster::Data::Result::ProblemStatus> | |
225 | ||
226 | =cut | |
227 | ||
228 | __PACKAGE__->has_many( | |
229 | "problem_statuses", | |
230 | "Gruntmaster::Data::Result::ProblemStatus", | |
231 | { "foreign.job" => "self.id" }, | |
232 | { cascade_copy => 0, cascade_delete => 0 }, | |
233 | ); | |
234 | ||
235 | ||
236 | # Created by DBIx::Class::Schema::Loader v0.07042 @ 2014-12-19 16:54:00 | |
237 | # DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:hEAVL5heV13+nalSmgr0WA | |
238 | ||
239 | use Class::Method::Modifiers qw/after/; | |
240 | ||
241 | sub rawcontest { shift->get_column('contest') } | |
242 | sub rawowner { shift->get_column('owner') } | |
243 | sub rawproblem { shift->get_column('problem') } | |
244 | ||
245 | sub rerun { | |
246 | shift->update({daemon => undef, result => -2, result_text => undef}); | |
247 | } | |
248 | ||
249 | after qw/insert update delete/ => sub { | |
250 | my ($self) = @_; | |
251 | Gruntmaster::Data::purge '/us/'; | |
252 | Gruntmaster::Data::purge '/us/' . $self->rawowner; | |
253 | Gruntmaster::Data::purge '/st/' . $self->rawcontest if $self->rawcontest; | |
254 | Gruntmaster::Data::purge '/log/'; | |
255 | Gruntmaster::Data::purge '/log/' . $self->id; | |
256 | }; | |
257 | ||
258 | 1; | |
259 | ||
260 | __END__ | |
261 | ||
262 | =head1 METHODS | |
263 | ||
264 | =head2 rerun | |
265 | ||
266 | Reruns this job. | |
267 | ||
268 | =head1 AUTHOR | |
269 | ||
270 | Marius Gavrilescu E<lt>marius@ieval.roE<gt> | |
271 | ||
272 | =head1 COPYRIGHT AND LICENSE | |
273 | ||
274 | Copyright (C) 2014 by Marius Gavrilescu | |
275 | ||
276 | This library is free software; you can redistribute it and/or modify | |
277 | it under the same terms as Perl itself, either Perl version 5.18.1 or, | |
278 | at your option, any later version of Perl 5 you may have available. | |
279 | ||
280 | ||
281 | =cut |