Added in network graph on about screen

This commit is contained in:
Deon George
2021-11-20 17:58:46 +11:00
parent 0be4ac0ad5
commit b333d38095
4 changed files with 105 additions and 8 deletions

View File

@@ -2,6 +2,7 @@
namespace App\Models;
use Carbon\Carbon;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Collection;
@@ -53,6 +54,21 @@ class Domain extends Model
/* METHODS */
public function daily_area_stats(): Collection
{
if (! $this->echoareas->count())
return collect();
$where = ['echoarea_id'=>$this->echoareas->pluck('id')->toArray()];
$echostats = Echomail::countGroupBy(['datetime',['datetime'=>'%Y-%m-%d']],$where);
return $echostats
->sortBy(function($item) { return $item->id->datetime; })
->map(function($item) { return ['x'=>Carbon::createFromFormat('Y-m-d',$item->id->datetime)->timestamp*1000,'y'=>$item->count]; })
->values();
}
public function stats(System $o=NULL): Collection
{
if (! $this->echoareas->count())
@@ -63,7 +79,7 @@ class Domain extends Model
if ($o)
$where->put('fftn_id',$o->addresses()->pluck('id'));
$echostats = Echomail::countGroupBy('echoarea_id',$where->toArray());
$echostats = Echomail::countGroupBy(['echoarea_id'],$where->toArray());
return $this->echoareas->map(function($item) use ($echostats) {
$stats = $echostats->filter(function($x) use ($item) {