From ab0de39c75a241233b05753856b887aa4196cbba Mon Sep 17 00:00:00 2001 From: = Date: Fri, 7 May 2021 21:00:55 +1000 Subject: [PATCH 1/2] Fixes for activities --- app/Models/Credit.php | 5 +++++ app/Models/Invoice.php | 2 +- app/Models/Quote.php | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/Models/Credit.php b/app/Models/Credit.php index e30838f9f5dc..6578a22788ab 100644 --- a/app/Models/Credit.php +++ b/app/Models/Credit.php @@ -128,6 +128,11 @@ class Credit extends BaseModel return $this->hasManyThrough(Backup::class, Activity::class); } + public function activities() + { + return $this->hasMany(Activity::class)->orderBy('id', 'DESC')->take(300); + } + public function company() { return $this->belongsTo(Company::class); diff --git a/app/Models/Invoice.php b/app/Models/Invoice.php index 63029682b962..d3da0af8b89f 100644 --- a/app/Models/Invoice.php +++ b/app/Models/Invoice.php @@ -204,7 +204,7 @@ class Invoice extends BaseModel public function activities() { - return $this->hasMany(Activity::class); + return $this->hasMany(Activity::class)->orderBy('id', 'DESC')->take(300); } public function history() diff --git a/app/Models/Quote.php b/app/Models/Quote.php index 2da173705b4d..7eba2847be45 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -130,6 +130,11 @@ class Quote extends BaseModel return $this->hasManyThrough(Backup::class, Activity::class); } + public function activities() + { + return $this->hasMany(Activity::class)->orderBy('id', 'DESC')->take(300); + } + public function user() { return $this->belongsTo(User::class)->withTrashed(); From 2e6471692a8c733241bee2da6cf37aa01bb08618 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Fri, 7 May 2021 23:29:02 +1000 Subject: [PATCH 2/2] Fixes for caching --- app/Jobs/Util/SchedulerCheck.php | 1 - app/Utils/Statics.php | 38 ++++++++++++++++---------------- 2 files changed, 19 insertions(+), 20 deletions(-) diff --git a/app/Jobs/Util/SchedulerCheck.php b/app/Jobs/Util/SchedulerCheck.php index c96be09f0078..adeb4e016079 100644 --- a/app/Jobs/Util/SchedulerCheck.php +++ b/app/Jobs/Util/SchedulerCheck.php @@ -53,7 +53,6 @@ class SchedulerCheck implements ShouldQueue try { Artisan::call('clear-compiled'); - Artisan::call('cache:clear'); Artisan::call('route:clear'); Artisan::call('config:cache'); } catch (\Exception $e) { diff --git a/app/Utils/Statics.php b/app/Utils/Statics.php index 5c9a95e9b6c8..a9ee3c192e2d 100644 --- a/app/Utils/Statics.php +++ b/app/Utils/Statics.php @@ -71,26 +71,26 @@ class Statics foreach (config('ninja.cached_tables') as $name => $class) { - if (!Cache::has($name)) { + // 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); - } - } + // // 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); + // } + // } $data[$name] = Cache::get($name); }