mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat: skip autostop reminder for active workspaces (#26772)
This commit is contained in:
Generated
+24
-1
@@ -38278,6 +38278,10 @@ WHERE
|
||||
-- * The workspace is not dormant and its owner is not suspended.
|
||||
-- * The build has a deadline in the future (we never remind about a stop already due).
|
||||
-- * The template opts in (time_til_autostop_notify > 0) and now is within the lead window.
|
||||
-- * The owner is not active in a way that can keep the workspace
|
||||
-- alive: either they have not used it within the active threshold
|
||||
-- (15 minutes), or activity bumps are disabled, or the max_deadline
|
||||
-- ceiling pins the stop inside the lead window so a bump cannot save it.
|
||||
-- * A reminder has not yet been sent for THIS deadline.
|
||||
--
|
||||
-- NOTE: time_til_autostop_notify has no upper bound. If it exceeds a
|
||||
@@ -38298,7 +38302,26 @@ WHERE
|
||||
workspace_builds.deadline > $1::timestamptz AND
|
||||
templates.time_til_autostop_notify > 0 AND
|
||||
workspace_builds.deadline <= ($1::timestamptz) + (INTERVAL '1 millisecond' * (templates.time_til_autostop_notify / 1000000)) AND
|
||||
workspace_builds.notified_autostop_deadline != workspace_builds.deadline
|
||||
workspace_builds.notified_autostop_deadline != workspace_builds.deadline AND
|
||||
-- Keep the reminder unless the user is active AND an activity bump can
|
||||
-- still move the deadline out of the lead window. This block is the
|
||||
-- exact complement of the skip-guard in shouldRemindAutostop (Go)
|
||||
-- (userActive AND bumpEnabled AND NOT maxDeadlineTraps), so the
|
||||
-- pre-filter and the re-check agree on the boundary.
|
||||
(
|
||||
-- Not used within the active threshold (15 minutes). This is the exact
|
||||
-- complement of the < autostopReminderActiveThreshold guard in
|
||||
-- shouldRemindAutostop (Go); keep the two in sync.
|
||||
($1 :: timestamptz) - workspaces.last_used_at >= INTERVAL '15 minutes'
|
||||
-- ...or activity bumps are disabled (deadline can't move)...
|
||||
OR templates.activity_bump <= 0
|
||||
-- ...or the hard max_deadline ceiling is within the lead window, so
|
||||
-- the workspace will stop regardless of activity.
|
||||
OR (
|
||||
workspace_builds.max_deadline != '0001-01-01 00:00:00+00'::timestamptz
|
||||
AND workspace_builds.max_deadline <= ($1::timestamptz) + (INTERVAL '1 millisecond' * (templates.time_til_autostop_notify / 1000000))
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
AND workspaces.deleted = 'false'
|
||||
|
||||
Reference in New Issue
Block a user