Cache our echo and file area stats for page rendering performance reasons
This commit is contained in:
parent
4b309871ec
commit
179233385b
@ -88,6 +88,7 @@ class Domain extends Model
|
||||
|
||||
public function echoarea_stats(): Collection
|
||||
{
|
||||
return Cache::remember(md5(sprintf('%d-%s',$this->id,__METHOD__)),self::CACHE_TIME,function() {
|
||||
$dt = Carbon::now()->startOfday();
|
||||
$case = CaseBuilder::whenRaw("datetime >= '?'",$dt->subDay()->format('Y-m-d'))->thenRaw("'day'")
|
||||
->whenRaw("datetime >= '?'",$dt->subDays(7)->format('Y-m-d'))->thenRaw("'week'")
|
||||
@ -104,6 +105,7 @@ class Domain extends Model
|
||||
->orderBy('echoareas.name')
|
||||
->orderBy('last_message','DESC')
|
||||
->get();
|
||||
});
|
||||
}
|
||||
|
||||
public function echoarea_total_daily(Collection $systems=NULL): Collection
|
||||
@ -126,6 +128,7 @@ class Domain extends Model
|
||||
|
||||
public function filearea_stats()
|
||||
{
|
||||
return Cache::remember(md5(sprintf('%d-%s',$this->id,__METHOD__)),self::CACHE_TIME,function() {
|
||||
$dt = Carbon::now()->startOfday();
|
||||
$case = CaseBuilder::whenRaw("datetime >= '?'",$dt->subDays(7)->format('Y-m-d'))->thenRaw("'week'")
|
||||
->whenRaw("datetime >= '?'",$dt->subMonth()->format('Y-m-d'))->thenRaw("'month'")
|
||||
@ -141,6 +144,7 @@ class Domain extends Model
|
||||
->orderBy('fileareas.name')
|
||||
->orderBy('last_file','DESC')
|
||||
->get();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user