From 519c09bb7e5fb62f7fa6da405eea55f5d01b96e0 Mon Sep 17 00:00:00 2001 From: "choi.jh" Date: Wed, 12 Nov 2025 15:05:44 +0900 Subject: [PATCH] trafficmonitor init...2 --- app/Controllers/CLI/Collector.php | 1 - app/Models/CollectorModel.php | 8 -------- app/Services/CollectorService.php | 6 +++++- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/app/Controllers/CLI/Collector.php b/app/Controllers/CLI/Collector.php index 3dab42e..e18e886 100644 --- a/app/Controllers/CLI/Collector.php +++ b/app/Controllers/CLI/Collector.php @@ -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"); } diff --git a/app/Models/CollectorModel.php b/app/Models/CollectorModel.php index ac6fd44..d66c29f 100644 --- a/app/Models/CollectorModel.php +++ b/app/Models/CollectorModel.php @@ -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(); // 첫 번째 레코드(=가장 최신) - } } diff --git a/app/Services/CollectorService.php b/app/Services/CollectorService.php index b6f71e6..91230bd 100644 --- a/app/Services/CollectorService.php +++ b/app/Services/CollectorService.php @@ -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 계산 가능