]>
Commit | Line | Data |
---|---|---|
4ed3f8e7 MG |
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 | ||
be2f7678 | 9 | Gruntmaster::Data::Result::Job - List of jobs |
4ed3f8e7 MG |
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 | |
b2725d9d | 37 | is_nullable: 1 |
4ed3f8e7 MG |
38 | |
39 | =head2 daemon | |
40 | ||
41 | data_type: 'text' | |
42 | is_nullable: 1 | |
43 | ||
be2f7678 MG |
44 | hostname:PID of daemon that last executed this job. NULL if never executed |
45 | ||
4ed3f8e7 MG |
46 | =head2 date |
47 | ||
48 | data_type: 'bigint' | |
49 | is_nullable: 0 | |
50 | ||
be2f7678 MG |
51 | Unix time when job was submitted |
52 | ||
4ed3f8e7 MG |
53 | =head2 errors |
54 | ||
55 | data_type: 'text' | |
56 | is_nullable: 1 | |
57 | ||
be2f7678 MG |
58 | Compiler errors |
59 | ||
4ed3f8e7 MG |
60 | =head2 extension |
61 | ||
62 | data_type: 'text' | |
63 | is_nullable: 0 | |
64 | ||
be2f7678 MG |
65 | File extension of submitted program, without a leading dot |
66 | ||
4ed3f8e7 MG |
67 | =head2 format |
68 | ||
69 | data_type: 'text' | |
70 | is_nullable: 0 | |
71 | ||
be2f7678 MG |
72 | Format (programming language) of submitted program |
73 | ||
4ed3f8e7 MG |
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 | ||
be2f7678 MG |
91 | Job result (integer constant from Gruntmaster::Daemon::Constants) |
92 | ||
4ed3f8e7 MG |
93 | =head2 result_text |
94 | ||
95 | data_type: 'text' | |
96 | is_nullable: 1 | |
97 | ||
be2f7678 MG |
98 | Job result (human-readable text) |
99 | ||
4ed3f8e7 MG |
100 | =head2 results |
101 | ||
85d3f015 | 102 | data_type: 'text' |
4ed3f8e7 MG |
103 | is_nullable: 1 |
104 | ||
be2f7678 MG |
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 | ||
4ed3f8e7 MG |
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", | |
b2725d9d | 129 | { data_type => "text", is_foreign_key => 1, is_nullable => 1 }, |
4ed3f8e7 MG |
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", | |
85d3f015 | 149 | { data_type => "text", is_nullable => 1 }, |
4ed3f8e7 MG |
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" }, | |
b2725d9d MG |
182 | { |
183 | is_deferrable => 0, | |
184 | join_type => "LEFT", | |
9bb39921 | 185 | on_delete => "CASCADE", |
b2725d9d MG |
186 | on_update => "NO ACTION", |
187 | }, | |
4ed3f8e7 MG |
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" }, | |
9bb39921 | 202 | { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" }, |
4ed3f8e7 MG |
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" }, | |
9bb39921 | 217 | { is_deferrable => 0, on_delete => "CASCADE", on_update => "NO ACTION" }, |
4ed3f8e7 MG |
218 | ); |
219 | ||
adb42d4d | 220 | =head2 problem_statuses |
4ed3f8e7 | 221 | |
adb42d4d MG |
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 | ||
be2f7678 MG |
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 | |
4ed3f8e7 | 238 | |
de7226ca MG |
239 | use Class::Method::Modifiers qw/after/; |
240 | ||
a2aa46e6 MG |
241 | sub rawcontest { shift->get_column('contest') } |
242 | sub rawowner { shift->get_column('owner') } | |
243 | sub rawproblem { shift->get_column('problem') } | |
244 | ||
4a8747ef MG |
245 | sub rerun { |
246 | shift->update({daemon => undef, result => -2, result_text => undef}); | |
247 | } | |
4ed3f8e7 | 248 | |
de7226ca MG |
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 | ||
4ed3f8e7 | 258 | 1; |
4a8747ef MG |
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 |