trafficmonitor init...2
This commit is contained in:
parent
2d6bb74ff0
commit
519c09bb7e
@ -29,7 +29,6 @@ class Collector extends CommonController
|
||||
foreach ($trafficService->getEntities(['status' => STATUS['AVAILABLE']]) as $entity) {
|
||||
$data = $this->service->getCalculatedData($entity);
|
||||
// Collector DB에 결과 저장
|
||||
dd($data);
|
||||
$this->service->create($this->createDTO($data));
|
||||
log_message('info', "트래픽 계산 및 저장 완료 (UID: {$entity->getPK()}), In: {$data['in_kbits_sec']} Kb/s");
|
||||
}
|
||||
|
||||
@ -26,12 +26,4 @@ class CollectorModel extends CommonModel
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function getLastEntity($uid): CollectorEntity|null
|
||||
{
|
||||
return $this
|
||||
->where('trafficinfo_uid', $uid)
|
||||
->orderBy('created_at', 'DESC')
|
||||
->first(); // 첫 번째 레코드(=가장 최신)
|
||||
}
|
||||
}
|
||||
|
||||
@ -109,7 +109,11 @@ class CollectorService extends CommonService
|
||||
throw new \Exception($message);
|
||||
}
|
||||
// 이전 데이터를 조회하여 Rate 계산에 사용
|
||||
$lastEntity = $this->model->getLastEntity($trafficEntity->getPK());
|
||||
$lastEntity = $this->model
|
||||
->where('trafficinfo_uid', $trafficEntity->getPK())
|
||||
->orderBy('created_at', 'DESC')
|
||||
->first();
|
||||
dd($lastEntity);
|
||||
$inKbitsSec = 0.0;
|
||||
$outKbitsSec = 0.0;
|
||||
// 이전 데이터가 있어야만 Rate 계산 가능
|
||||
|
||||
Loading…
Reference in New Issue
Block a user