From 8e1151555c7383bdd4e9baca68e6fa29b48cbd29 Mon Sep 17 00:00:00 2001 From: Moritz Bunkus Date: Tue, 3 Jun 2014 17:10:44 +0200 Subject: [PATCH] RDBO BackgroundJob(History): Refactoring von Status-Strings --- SL/DB/BackgroundJob.pm | 4 ++-- SL/DB/BackgroundJobHistory.pm | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/SL/DB/BackgroundJob.pm b/SL/DB/BackgroundJob.pm index e8ae55bac..b567d364e 100644 --- a/SL/DB/BackgroundJob.pm +++ b/SL/DB/BackgroundJob.pm @@ -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; diff --git a/SL/DB/BackgroundJobHistory.pm b/SL/DB/BackgroundJobHistory.pm index 145548039..84b2cb771 100644 --- a/SL/DB/BackgroundJobHistory.pm +++ b/SL/DB/BackgroundJobHistory.pm @@ -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; -- 2.20.1