trafficmonitor init...2

This commit is contained in:
choi.jh 2025-11-12 15:06:45 +09:00
parent 519c09bb7e
commit da9f79b32b
2 changed files with 9 additions and 5 deletions

View File

@ -26,4 +26,12 @@ 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,11 +109,7 @@ class CollectorService extends CommonService
throw new \Exception($message); throw new \Exception($message);
} }
// 이전 데이터를 조회하여 Rate 계산에 사용 // 이전 데이터를 조회하여 Rate 계산에 사용
$lastEntity = $this->model $lastEntity = $this->model->getLastEntity($trafficEntity->getPK());
->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 계산 가능