Private
Public Access
1
0

fix(api): handle score monitors in name-based lookups

Score monitors have type='score' and ip_version=NULL, but the
GetMonitorByNameAndIPVersion query required ip_version to match.
This broke monitor lookups by name for score monitors.

Modified query to match either:
- Regular monitors with specified ip_version
- Score monitors with NULL ip_version

Fixes issue reported by Ben Harris at:
https://community.ntppool.org/t/monitor-recentmedian-no-longer-works/4002
This commit is contained in:
2025-08-04 20:43:53 -07:00
parent 393d532ce2
commit 9c6b8d1867
2 changed files with 2 additions and 2 deletions

View File

@@ -16,7 +16,7 @@ const getMonitorByNameAndIPVersion = `-- name: GetMonitorByNameAndIPVersion :one
select id, id_token, type, user_id, account_id, hostname, location, ip, ip_version, tls_name, api_key, status, config, client_version, last_seen, last_submit, created_on, deleted_on, is_current from monitors
where
tls_name like ? AND
ip_version = ? AND
(ip_version = ? OR (type = 'score' AND ip_version IS NULL)) AND
is_current = 1 AND
status != 'deleted'
order by id

View File

@@ -51,7 +51,7 @@ where
select * from monitors
where
tls_name like sqlc.arg('tls_name') AND
ip_version = sqlc.arg('ip_version') AND
(ip_version = sqlc.arg('ip_version') OR (type = 'score' AND ip_version IS NULL)) AND
is_current = 1 AND
status != 'deleted'
order by id