Skip to content

Commit

Permalink
Merge pull request #2 from Peatix/feature-worklog
Browse files Browse the repository at this point in the history
feature:Add text logging on exitstatus.
  • Loading branch information
aklaswad authored Jan 9, 2019
2 parents 2526fad + e853722 commit b6e491a
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
3 changes: 2 additions & 1 deletion doc/schema-postgres.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ CREATE TABLE exitstatus (
funcid INT NOT NULL DEFAULT 0,
status SMALLINT,
completion_time INTEGER,
delete_after INTEGER
delete_after INTEGER,
note MEDIUMTEXT
);

CREATE INDEX exitstatus_funcid ON exitstatus (funcid);
Expand Down
1 change: 1 addition & 0 deletions doc/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ CREATE TABLE exitstatus (
status SMALLINT UNSIGNED,
completion_time INTEGER UNSIGNED,
delete_after INTEGER UNSIGNED,
note MEDIUMTEXT,
INDEX (funcid),
INDEX (delete_after)
);
2 changes: 1 addition & 1 deletion lib/TheSchwartz/ExitStatus.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use base qw( Data::ObjectDriver::BaseObject );
__PACKAGE__->install_properties(
{ columns => [
qw( jobid status funcid
completion_time delete_after )
completion_time delete_after note )
],
datasource => 'exitstatus',
primary_key => 'jobid',
Expand Down
7 changes: 7 additions & 0 deletions lib/TheSchwartz/Job.pm
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ sub set_exit_status {
$status->completion_time(time);
$status->delete_after( $status->completion_time + $secs );
$status->status($exit);
$status->note( join "\n", @{$job->{__note} || []} );

my $driver = $job->driver;
$driver->insert($status);
Expand Down Expand Up @@ -359,6 +360,12 @@ sub _cond_thaw {
}
}

sub note {
my $job = shift;
my $note = $job->{__note} //= [];
push @$note, @_;
}

1;

__END__
Expand Down
3 changes: 2 additions & 1 deletion t/schema-sqlite.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ CREATE TABLE exitstatus (
funcid INT UNSIGNED NOT NULL DEFAULT 0,
status SMALLINT UNSIGNED,
completion_time INTEGER UNSIGNED,
delete_after INTEGER UNSIGNED
delete_after INTEGER UNSIGNED,
note MEDIUMTEXT
);

0 comments on commit b6e491a

Please sign in to comment.