From e6515e5b366c1f040a4f7e1ae09cf48eee8962d4 Mon Sep 17 00:00:00 2001 From: pro Date: Thu, 29 Jan 2026 17:10:42 +0900 Subject: [PATCH] =?UTF-8?q?fix:=EC=A7=84=ED=96=89=EB=A5=A0=20=EA=B3=84?= =?UTF-8?q?=EC=82=B0=20=EC=8B=9C=20config=EC=97=90=20=EC=A1=B4=EC=9E=AC?= =?UTF-8?q?=ED=95=98=EB=8A=94=20=EC=B2=B4=ED=81=AC=ED=8F=AC=EC=9D=B8?= =?UTF-8?q?=ED=8A=B8=EB=A7=8C=20=EC=B9=B4=EC=9A=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 체크포인트 축소 시 DB에 남아있는 이전 데이터 때문에 100% 초과 문제 수정 - validCheckpointKeys 배열로 config 기준 유효성 검증 Co-Authored-By: Claude Opus 4.5 --- app/Models/Sales/SalesScenarioChecklist.php | 22 +++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/app/Models/Sales/SalesScenarioChecklist.php b/app/Models/Sales/SalesScenarioChecklist.php index 97f8d1df..65d261a2 100644 --- a/app/Models/Sales/SalesScenarioChecklist.php +++ b/app/Models/Sales/SalesScenarioChecklist.php @@ -188,15 +188,29 @@ public static function getSimpleProgress(int $tenantId, string $scenarioType): a $steps = config($configKey, []); $total = 0; + $validCheckpointKeys = []; + + // config에 정의된 유효한 체크포인트만 수집 foreach ($steps as $step) { - $total += count($step['checkpoints'] ?? []); + foreach ($step['checkpoints'] ?? [] as $checkpoint) { + $total++; + $validCheckpointKeys[] = "{$step['id']}_{$checkpoint['id']}"; + } } - // 완료된 체크포인트 수 (DB에서 조회) - $completed = self::where('tenant_id', $tenantId) + // 완료된 체크포인트 수 (config에 존재하는 것만 카운트) + $checkedItems = self::where('tenant_id', $tenantId) ->where('scenario_type', $scenarioType) ->where('is_checked', true) - ->count(); + ->get(); + + $completed = 0; + foreach ($checkedItems as $item) { + $key = "{$item->step_id}_{$item->checkpoint_id}"; + if (in_array($key, $validCheckpointKeys)) { + $completed++; + } + } $percentage = $total > 0 ? round(($completed / $total) * 100) : 0;