fix:진행률 계산 시 config에 존재하는 체크포인트만 카운트

- 체크포인트 축소 시 DB에 남아있는 이전 데이터 때문에 100% 초과 문제 수정
- validCheckpointKeys 배열로 config 기준 유효성 검증

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
pro
2026-01-29 17:10:42 +09:00
parent 24ee38ab80
commit e6515e5b36

View File

@@ -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;