User dashboard caching
This commit is contained in:
@@ -61,7 +61,7 @@ class Domain extends Model
|
||||
if (! $this->echoareas->count())
|
||||
return collect();
|
||||
|
||||
$key = sprintf('%s_%d','daily_echoarea_stats',$this->id);
|
||||
$key = sprintf('%s_%d','daily_area_stats',$this->id);
|
||||
|
||||
return Cache::driver('redis')->remember($key,self::CACHE_TIME,function() {
|
||||
$where = ['echoarea_id'=>$this->echoareas->pluck('id')->toArray()];
|
||||
@@ -99,24 +99,28 @@ class Domain extends Model
|
||||
if (! $this->echoareas->count())
|
||||
return collect();
|
||||
|
||||
$where = collect(['echoarea_id'=>$this->echoareas->pluck('id')->toArray()]);
|
||||
$key = sprintf('%s_%d_%d','stats',$this->id,$o?->id);
|
||||
|
||||
if ($o)
|
||||
$where->put('fftn_id',$o->addresses()->pluck('id'));
|
||||
return Cache::driver('redis')->remember($key,self::CACHE_TIME,function() use ($o) {
|
||||
$where = collect(['echoarea_id'=>$this->echoareas->pluck('id')->toArray()]);
|
||||
|
||||
$echostats = Echomail::countGroupBy(['echoarea_id'],$where->toArray());
|
||||
if ($o)
|
||||
$where->put('fftn_id',$o->addresses()->pluck('id'));
|
||||
|
||||
return $this->echoareas->map(function($item) use ($echostats) {
|
||||
$stats = $echostats->filter(function($x) use ($item) {
|
||||
return $x->id->echoarea_id == $item->id;
|
||||
$echostats = Echomail::countGroupBy(['echoarea_id'],$where->toArray());
|
||||
|
||||
return $this->echoareas->map(function($item) use ($echostats) {
|
||||
$stats = $echostats->filter(function($x) use ($item) {
|
||||
return $x->id->echoarea_id == $item->id;
|
||||
});
|
||||
|
||||
$item->count = 0;
|
||||
|
||||
foreach ($stats as $o)
|
||||
$item->count += $o->count;
|
||||
|
||||
return $item;
|
||||
});
|
||||
|
||||
$item->count = 0;
|
||||
|
||||
foreach ($stats as $o)
|
||||
$item->count += $o->count;
|
||||
|
||||
return $item;
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user