Revert "Fix grouped duration_seconds overcounting by using global LAG instead…" (#1077)

This reverts commit 972d6d2e33.
This commit is contained in:
Mahad Kalam 2026-03-15 21:51:17 +00:00 committed by GitHub
parent d38b7f71f5
commit b915f6d4d9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -223,8 +223,8 @@ module Heartbeatable
capped_diffs = scope
.select("#{group_expr} as grouped_time, CASE
WHEN LAG(time) OVER (ORDER BY time) IS NULL THEN 0
ELSE LEAST(time - LAG(time) OVER (ORDER BY time), #{timeout})
WHEN LAG(time) OVER (PARTITION BY #{group_expr} ORDER BY time) IS NULL THEN 0
ELSE LEAST(time - LAG(time) OVER (PARTITION BY #{group_expr} ORDER BY time), #{timeout})
END as diff")
.where.not(time: nil)
.unscope(:group)