better logging for jobs

This commit is contained in:
paulwer 2023-12-18 15:58:16 +01:00
parent e4d0c9f901
commit 1060dad7d7
2 changed files with 11 additions and 11 deletions

View File

@ -67,14 +67,16 @@ class ProcessBankTransactionsNordigen implements ShouldQueue
set_time_limit(0); set_time_limit(0);
nlog("Nordigen: Processing transactions for account: {$this->bank_integration->account->key}");
// UPDATE ACCOUNT // UPDATE ACCOUNT
try { try {
$this->updateAccount(); $this->updateAccount();
} catch (\Exception $e) { } catch (\Exception $e) {
nlog("{$this->bank_integration->account->key} - exited abnormally => " . $e->getMessage()); nlog("Nordigen: {$this->bank_integration->nordigen_account_id} - exited abnormally => " . $e->getMessage());
$content = [ $content = [
"Processing transactions for account: {$this->bank_integration->account->key} failed", "Processing transactions for account: {$this->bank_integration->nordigen_account_id} failed",
"Exception Details => ", "Exception Details => ",
$e->getMessage(), $e->getMessage(),
]; ];
@ -94,10 +96,10 @@ class ProcessBankTransactionsNordigen implements ShouldQueue
$this->bank_integration->from_date = now()->subDays(90); $this->bank_integration->from_date = now()->subDays(90);
$this->bank_integration->save(); $this->bank_integration->save();
nlog("{$this->bank_integration->account->key} - exited abnormally => " . $e->getMessage()); nlog("Nordigen: {$this->bank_integration->nordigen_account_id} - exited abnormally => " . $e->getMessage());
$content = [ $content = [
"Processing transactions for account: {$this->bank_integration->account->key} failed", "Processing transactions for account: {$this->bank_integration->nordigen_account_id} failed",
"Exception Details => ", "Exception Details => ",
$e->getMessage(), $e->getMessage(),
]; ];
@ -114,13 +116,11 @@ class ProcessBankTransactionsNordigen implements ShouldQueue
private function updateAccount() private function updateAccount()
{ {
Log::info("try to execute updateAccount");
if (!$this->nordigen->isAccountActive($this->bank_integration->nordigen_account_id)) { if (!$this->nordigen->isAccountActive($this->bank_integration->nordigen_account_id)) {
$this->bank_integration->disabled_upstream = true; $this->bank_integration->disabled_upstream = true;
$this->bank_integration->save(); $this->bank_integration->save();
$this->stop_loop = false; $this->stop_loop = false;
Log::info("account inactive"); Log::info("Nordigen: account inactive: " . $this->bank_integration->nordigen_account_id);
// @turbo124 @todo send email for expired account // @turbo124 @todo send email for expired account
return; return;
} }

View File

@ -71,16 +71,16 @@ class ProcessBankTransactionsYodlee implements ShouldQueue
//Loop through everything until we are up to date //Loop through everything until we are up to date
$this->from_date = $this->from_date ?: '2021-01-01'; $this->from_date = $this->from_date ?: '2021-01-01';
nlog("Processing transactions for account: {$this->bank_integration->account->key}"); nlog("Yodlee: Processing transactions for account: {$this->bank_integration->account->key}");
do { do {
try { try {
$this->processTransactions(); $this->processTransactions();
} catch (\Exception $e) { } catch (\Exception $e) {
nlog("{$this->account->bank_integration_account_id} - exited abnormally => " . $e->getMessage()); nlog("Yodlee: {$this->bank_integration->bank_account_id} - exited abnormally => " . $e->getMessage());
$content = [ $content = [
"Processing transactions for account: {$this->bank_integration->account->key} failed", "Processing transactions for account: {$this->bank_integration->bank_account_id} failed",
"Exception Details => ", "Exception Details => ",
$e->getMessage(), $e->getMessage(),
]; ];
@ -164,7 +164,7 @@ class ProcessBankTransactionsYodlee implements ShouldQueue
$now = now(); $now = now();
foreach ($transactions as $transaction) { foreach ($transactions as $transaction) {
if (BankTransaction::query()->where('transaction_id', $transaction['transaction_id'])->where('company_id', $this->company->id)->withTrashed()->exists()) { if (BankTransaction::query()->where('transaction_id', $transaction['transaction_id'])->where('company_id', $this->company->id)->where('bank_integration_id', $this->bank_integration->id)->withTrashed()->exists()) { // @turbo124 was not scoped to bank_integration_id => from my pov this should be present, because when an account was historized (is_deleted) a transaction can occur multiple (in the archived bank_integration and in the new one
continue; continue;
} }