trafficmonitor init...2

This commit is contained in:
choi.jh 2025-11-12 15:05:44 +09:00
parent 2d6bb74ff0
commit 519c09bb7e
3 changed files with 5 additions and 10 deletions

View File

@ -29,7 +29,6 @@ class Collector extends CommonController
foreach ($trafficService->getEntities(['status' => STATUS['AVAILABLE']]) as $entity) { foreach ($trafficService->getEntities(['status' => STATUS['AVAILABLE']]) as $entity) {
$data = $this->service->getCalculatedData($entity); $data = $this->service->getCalculatedData($entity);
// Collector DB에 결과 저장 // Collector DB에 결과 저장
dd($data);
$this->service->create($this->createDTO($data)); $this->service->create($this->createDTO($data));
log_message('info', "트래픽 계산 및 저장 완료 (UID: {$entity->getPK()}), In: {$data['in_kbits_sec']} Kb/s"); log_message('info', "트래픽 계산 및 저장 완료 (UID: {$entity->getPK()}), In: {$data['in_kbits_sec']} Kb/s");
} }

View File

@ -26,12 +26,4 @@ class CollectorModel extends CommonModel
{ {
parent::__construct(); parent::__construct();
} }
public function getLastEntity($uid): CollectorEntity|null
{
return $this
->where('trafficinfo_uid', $uid)
->orderBy('created_at', 'DESC')
->first(); // 첫 번째 레코드(=가장 최신)
}
} }

View File

@ -109,7 +109,11 @@ class CollectorService extends CommonService
throw new \Exception($message); throw new \Exception($message);
} }
// 이전 데이터를 조회하여 Rate 계산에 사용 // 이전 데이터를 조회하여 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; $inKbitsSec = 0.0;
$outKbitsSec = 0.0; $outKbitsSec = 0.0;
// 이전 데이터가 있어야만 Rate 계산 가능 // 이전 데이터가 있어야만 Rate 계산 가능