修复勤务日榜在线时长:CASE WHEN 实时算 open session 时长;关闭 stale 日志时补算 duration_seconds

This commit is contained in:
2026-03-18 21:03:36 +08:00
parent afd02b38e3
commit 42beed5c93
2 changed files with 13 additions and 1 deletions
@@ -50,6 +50,8 @@ class CloseStaleDutyLogs extends Command
->where('updated_at', '<=', $threshold)
->update([
'logout_at' => DB::raw('NOW()'),
// 补算最终在线时长,避免日榜 SUM 使用过时的旧值
'duration_seconds' => DB::raw('GREATEST(0, TIMESTAMPDIFF(SECOND, login_at, NOW()))'),
]);
if ($affected > 0) {