fix: [attendance] 주간 근무시간 계산 UNSIGNED 오버플로우 수정
- CAST(... AS UNSIGNED)에서 음수값 시 2^64-1로 오버플로우되던 버그 - CAST(... AS SIGNED) + COALESCE + GREATEST(0, ...)로 안전하게 변경 - getOvertimeAlerts(), getEmployeeMonthlySummary() 두 곳 수정
This commit is contained in:
@@ -357,7 +357,7 @@ public function getEmployeeMonthlySummary(int $year, int $month): array
|
||||
'user_id',
|
||||
'status',
|
||||
DB::raw('COUNT(*) as cnt'),
|
||||
DB::raw("SUM(CAST(JSON_UNQUOTE(JSON_EXTRACT(json_details, '$.work_minutes')) AS UNSIGNED)) as total_minutes")
|
||||
DB::raw("SUM(GREATEST(0, COALESCE(CAST(JSON_UNQUOTE(JSON_EXTRACT(json_details, '$.work_minutes')) AS SIGNED), 0))) as total_minutes")
|
||||
)
|
||||
->groupBy('user_id', 'status')
|
||||
->get();
|
||||
@@ -409,7 +409,7 @@ public function getOvertimeAlerts(): array
|
||||
->betweenDates($weekStart, $weekEnd)
|
||||
->select(
|
||||
'user_id',
|
||||
DB::raw("SUM(CAST(JSON_UNQUOTE(JSON_EXTRACT(json_details, '$.work_minutes')) AS UNSIGNED)) as week_minutes")
|
||||
DB::raw("SUM(GREATEST(0, COALESCE(CAST(JSON_UNQUOTE(JSON_EXTRACT(json_details, '$.work_minutes')) AS SIGNED), 0))) as week_minutes")
|
||||
)
|
||||
->groupBy('user_id')
|
||||
->having('week_minutes', '>=', 2880) // 48시간 = 2880분
|
||||
|
||||
Reference in New Issue
Block a user