From 7a96c25f8b9d48dd7ea0250881e8eedc32fb34c2 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 12 Oct 2023 17:29:24 +1100 Subject: [PATCH 1/3] Only return messages with an event --- app/Http/Controllers/EmailHistoryController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/EmailHistoryController.php b/app/Http/Controllers/EmailHistoryController.php index 42dea4c1625a..4da69ba7b6dc 100644 --- a/app/Http/Controllers/EmailHistoryController.php +++ b/app/Http/Controllers/EmailHistoryController.php @@ -32,7 +32,7 @@ class EmailHistoryController extends BaseController ->orderBy('id', 'DESC') ->cursor() ->map(function ($system_log) { - if($system_log->log['history'] ?? false) { + if(($system_log->log['history'] && $system_log->log['history']['events'] && count($system_log->log['history']['events']) >=1) ?? false) { return $system_log->log['history']; } }); @@ -57,7 +57,7 @@ class EmailHistoryController extends BaseController ->orderBy('id', 'DESC') ->cursor() ->map(function ($system_log) { - if($system_log->log['history'] ?? false) { + if(($system_log->log['history'] && $system_log->log['history']['events'] && count($system_log->log['history']['events']) >=1) ?? false) { return $system_log->log['history']; } }); From 999ead0fec2947c03057d2881c05e8a2e8f4e868 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 13 Oct 2023 21:14:37 +1100 Subject: [PATCH 2/3] Updates for translations --- app/Services/Client/ClientService.php | 50 ++++++++++++++++++++++++--- lang/en/texts.php | 1 + 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/app/Services/Client/ClientService.php b/app/Services/Client/ClientService.php index 96878cd2480e..8aabdbcbf487 100644 --- a/app/Services/Client/ClientService.php +++ b/app/Services/Client/ClientService.php @@ -44,6 +44,19 @@ class ClientService }, 2); } catch (\Throwable $throwable) { nlog("DB ERROR " . $throwable->getMessage()); + DB::connection(config('database.default'))->rollBack(); + + if (DB::connection(config('database.default'))->transactionLevel() > 0) { + DB::connection(config('database.default'))->rollBack(); + } + + } catch(\Exception $exception){ + nlog("DB ERROR " . $exception->getMessage()); + DB::connection(config('database.default'))->rollBack(); + + if (DB::connection(config('database.default'))->transactionLevel() > 0) { + DB::connection(config('database.default'))->rollBack(); + } } return $this; @@ -60,6 +73,17 @@ class ClientService }, 2); } catch (\Throwable $throwable) { nlog("DB ERROR " . $throwable->getMessage()); + + if (DB::connection(config('database.default'))->transactionLevel() > 0) { + DB::connection(config('database.default'))->rollBack(); + } + + } catch(\Exception $exception){ + nlog("DB ERROR " . $exception->getMessage()); + + if (DB::connection(config('database.default'))->transactionLevel() > 0) { + DB::connection(config('database.default'))->rollBack(); + } } return $this; @@ -67,11 +91,27 @@ class ClientService public function updatePaidToDate(float $amount) { - DB::connection(config('database.default'))->transaction(function () use ($amount) { - $this->client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first(); - $this->client->paid_to_date += $amount; - $this->client->saveQuietly(); - }, 2); + try { + DB::connection(config('database.default'))->transaction(function () use ($amount) { + $this->client = Client::withTrashed()->where('id', $this->client->id)->lockForUpdate()->first(); + $this->client->paid_to_date += $amount; + $this->client->saveQuietly(); + }, 2); + } + catch (\Throwable $throwable) { + nlog("DB ERROR " . $throwable->getMessage()); + + if (DB::connection(config('database.default'))->transactionLevel() > 0) { + DB::connection(config('database.default'))->rollBack(); + } + + } catch(\Exception $exception){ + nlog("DB ERROR " . $exception->getMessage()); + + if (DB::connection(config('database.default'))->transactionLevel() > 0) { + DB::connection(config('database.default'))->rollBack(); + } + } return $this; } diff --git a/lang/en/texts.php b/lang/en/texts.php index a1c32b256f7c..49eb412a6202 100644 --- a/lang/en/texts.php +++ b/lang/en/texts.php @@ -5179,6 +5179,7 @@ $LANG = array( 'stock_quantity_number' => 'Stock :quantity', 'upcoming' => 'Upcoming', 'client_contact' => 'Client Contact', + 'uncategorized' => 'Uncategorized', ); return $LANG; From 6e926664003626c7a3b6078b4b6358b46f3aaa65 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 13 Oct 2023 21:18:03 +1100 Subject: [PATCH 3/3] Fixes for randomdataseeder --- database/seeders/RandomDataSeeder.php | 27 +++------------------------ 1 file changed, 3 insertions(+), 24 deletions(-) diff --git a/database/seeders/RandomDataSeeder.php b/database/seeders/RandomDataSeeder.php index 027fad32815a..812c1ee9e6ec 100644 --- a/database/seeders/RandomDataSeeder.php +++ b/database/seeders/RandomDataSeeder.php @@ -47,11 +47,12 @@ use App\Repositories\InvoiceRepository; use Illuminate\Database\Eloquent\Model; use App\Events\Payment\PaymentWasCreated; use App\Helpers\Invoice\InvoiceSumInclusive; +use App\Utils\Traits\AppSetup; class RandomDataSeeder extends Seeder { use \App\Utils\Traits\MakesHash; - + use AppSetup; /** * Run the database seeds. * @@ -59,30 +60,8 @@ class RandomDataSeeder extends Seeder */ public function run() { - /* Warm up the cache !*/ - $cached_tables = config('ninja.cached_tables'); - foreach ($cached_tables as $name => $class) { - if (! Cache::has($name)) { - // check that the table exists in case the migration is pending - if (! Schema::hasTable((new $class())->getTable())) { - continue; - } - if ($name == 'payment_terms') { - $orderBy = 'num_days'; - } elseif ($name == 'fonts') { - $orderBy = 'sort_order'; - } elseif (in_array($name, ['currencies', 'industries', 'languages', 'countries', 'banks'])) { - $orderBy = 'name'; - } else { - $orderBy = 'id'; - } - $tableData = $class::orderBy($orderBy)->get(); - if ($tableData->count()) { - Cache::forever($name, $tableData); - } - } - } + $this->buildCache(true); $this->command->info('Running RandomDataSeeder');