fix(alerts): remove dead ACKNOWLEDGED enum SQL + TODO comments

Remove SET state='ACKNOWLEDGED' from ack() and the ACKNOWLEDGED predicate
from findOpenForRule — both would error after V17. The final ack() + open-rule
semantics (idempotent guards, deleted_at) are owned by Task 5; this is just
the minimum to stop runtime SQL errors.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
hsiegeln
2026-04-21 17:36:02 +02:00
parent 5b1b3f215a
commit 6e8d890442
5 changed files with 10 additions and 12 deletions

View File

@@ -87,7 +87,8 @@ public class PostgresAlertInstanceRepository implements AlertInstanceRepository
var list = jdbc.query("""
SELECT * FROM alert_instances
WHERE rule_id = ?
AND state IN ('PENDING','FIRING','ACKNOWLEDGED')
AND state IN ('PENDING','FIRING')
AND deleted_at IS NULL
LIMIT 1
""", rowMapper(), ruleId);
return list.isEmpty() ? Optional.empty() : Optional.of(list.get(0));
@@ -158,9 +159,8 @@ public class PostgresAlertInstanceRepository implements AlertInstanceRepository
public void ack(UUID id, String userId, Instant when) {
jdbc.update("""
UPDATE alert_instances
SET state = 'ACKNOWLEDGED'::alert_state_enum,
acked_at = ?, acked_by = ?
WHERE id = ?
SET acked_at = ?, acked_by = ?
WHERE id = ? AND acked_at IS NULL AND deleted_at IS NULL
""", Timestamp.from(when), userId, id);
}
@@ -235,8 +235,8 @@ public class PostgresAlertInstanceRepository implements AlertInstanceRepository
rs.getString("acked_by"),
resolvedAt == null ? null : resolvedAt.toInstant(),
lastNotifiedAt == null ? null : lastNotifiedAt.toInstant(),
null, // readAt — TODO Task 4: read from DB column
null, // deletedAt — TODO Task 4: read from DB column
null,
null,
rs.getBoolean("silenced"),
currentValue,
threshold,