RDBO BackgroundJob(History): Refactoring von Status-Strings
authorMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 3 Jun 2014 15:10:44 +0000 (17:10 +0200)
committerMoritz Bunkus <m.bunkus@linet-services.de>
Tue, 3 Jun 2014 15:10:44 +0000 (17:10 +0200)
SL/DB/BackgroundJob.pm
SL/DB/BackgroundJobHistory.pm

index e8ae55b..b567d36 100644 (file)
@@ -45,7 +45,7 @@ sub run {
     $history = SL::DB::BackgroundJobHistory
       ->new(package_name => $self->package_name,
             run_at       => $run_at,
-            status       => 'success',
+            status       => SL::DB::BackgroundJobHistory::SUCCESS(),
             result       => $result,
             data         => $self->data);
     $history->save;
@@ -58,7 +58,7 @@ sub run {
     $history = SL::DB::BackgroundJobHistory
       ->new(package_name => $self->package_name,
             run_at       => $run_at,
-            status       => 'failure',
+            status       => SL::DB::BackgroundJobHistory::FAILURE(),
             error_col    => $error,
             data         => $self->data);
     $history->save;
index 1455480..84b2cb7 100644 (file)
@@ -1,6 +1,3 @@
-# This file has been auto-generated only because it didn't exist.
-# Feel free to modify it at will; it will not be overwritten automatically.
-
 package SL::DB::BackgroundJobHistory;
 
 use strict;
@@ -10,4 +7,10 @@ use SL::DB::Manager::BackgroundJobHistory;
 
 __PACKAGE__->meta->initialize;
 
+use constant SUCCESS => 'success';
+use constant FAILURE => 'failure';
+
+sub has_succeeded { $_[0] && (($_[0]->status || '') eq SUCCESS()) }
+sub has_failed    { $_[0] && (($_[0]->status || '') eq FAILURE()) }
+
 1;