1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #5639 from turbo124/v5-develop

Fixes for caching
This commit is contained in:
David Bomba 2021-05-07 23:29:32 +10:00 committed by GitHub
commit e700ac3095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 30 additions and 21 deletions

View File

@ -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) {

View File

@ -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);

View File

@ -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()

View File

@ -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();

View File

@ -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);
}