From 08b184218f2e4937b9696aee23b1b38ab50471e2 Mon Sep 17 00:00:00 2001 From: Rene Krenn Date: Thu, 22 Oct 2015 08:48:47 +0200 Subject: [PATCH] MT#14557 fix '1970-01-...' lock detection timestamps Change-Id: I540a7c743749294a76c0cce07b12c407ea53073f --- rate-o-mat.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rate-o-mat.pl b/rate-o-mat.pl index 7d0ee21..09c9fdf 100755 --- a/rate-o-mat.pl +++ b/rate-o-mat.pl @@ -519,13 +519,13 @@ EOS $sth_new_cbalance = $billdbh->prepare( "INSERT INTO billing.contract_balances (". " contract_id, cash_balance, cash_balance_interval, free_time_balance, free_time_balance_interval, underrun_profiles, underrun_lock, start, end". - ") VALUES (?, ?, ?, ?, ?, FROM_UNIXTIME(?), FROM_UNIXTIME(?), FROM_UNIXTIME(?), FROM_UNIXTIME(?))" + ") VALUES (?, ?, ?, ?, ?, IF(? = 0, NULL, FROM_UNIXTIME(?)), IF(? = 0, NULL, FROM_UNIXTIME(?)), FROM_UNIXTIME(?), FROM_UNIXTIME(?))" ) or FATAL "Error preparing create contract balance statement: ".$billdbh->errstr; $sth_new_cbalance_infinite_future = $billdbh->prepare( "INSERT INTO billing.contract_balances (". " contract_id, cash_balance, cash_balance_interval, free_time_balance, free_time_balance_interval, underrun_profiles, underrun_lock, start, end". - ") VALUES (?, ?, ?, ?, ?, FROM_UNIXTIME(?), FROM_UNIXTIME(?), FROM_UNIXTIME(?), '9999-12-31 23:59:59')" + ") VALUES (?, ?, ?, ?, ?, IF(? = 0, NULL, FROM_UNIXTIME(?)), IF(? = 0, NULL, FROM_UNIXTIME(?)), FROM_UNIXTIME(?), '9999-12-31 23:59:59')" ) or FATAL "Error preparing create contract balance statement: ".$billdbh->errstr; $sth_update_cbalance_w_underrun_profiles_lock = $billdbh->prepare( @@ -1053,7 +1053,7 @@ PREPARE_BALANCE_CATCHUP: sprintf("%.0f",$free_time_balance), sprintf("%.0f",$free_time_balance_interval)); my @bind_parms = ($contract_id, $last_cash_balance,$last_cash_balance_int,$last_free_balance,$last_free_balance_int, - $underrun_profiles_time,$underrun_lock_time,$stime); + ((defined $underrun_profiles_time ? $underrun_profiles_time : 0)) x 2,((defined $underrun_lock_time ? $underrun_lock_time : 0)) x 2,$stime); push(@bind_parms,$etime) if defined $etime; $sth->execute(@bind_parms) or FATAL "Error executing new contract balance statement: ".$sth->errstr;