fix(scheduler): убрать двойной SaveCheckRun (Checker персистит), SetDrift через CountDriftDomains, resolved после error
This commit is contained in:
@@ -12,6 +12,17 @@ import (
|
||||
dto "github.com/vasyakrg/dns-autoresolver/internal/store/dto"
|
||||
)
|
||||
|
||||
const countDriftDomains = `-- name: CountDriftDomains :one
|
||||
SELECT count(*) FROM domains WHERE last_check_status = 'drift'
|
||||
`
|
||||
|
||||
func (q *Queries) CountDriftDomains(ctx context.Context) (int64, error) {
|
||||
row := q.db.QueryRow(ctx, countDriftDomains)
|
||||
var count int64
|
||||
err := row.Scan(&count)
|
||||
return count, err
|
||||
}
|
||||
|
||||
const createDomain = `-- name: CreateDomain :one
|
||||
INSERT INTO domains (id, project_id, provider_account_id, zone_name, zone_id, template_id)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)
|
||||
|
||||
@@ -34,3 +34,6 @@ SELECT last_check_status FROM domains WHERE id = $1;
|
||||
|
||||
-- name: SetDomainStatus :exec
|
||||
UPDATE domains SET last_check_status = $2 WHERE id = $1;
|
||||
|
||||
-- name: CountDriftDomains :one
|
||||
SELECT count(*) FROM domains WHERE last_check_status = 'drift';
|
||||
|
||||
@@ -258,6 +258,14 @@ func (s *Store) SetDomainStatus(ctx context.Context, domainID uuid.UUID, status
|
||||
return s.q.SetDomainStatus(ctx, db.SetDomainStatusParams{ID: domainID, LastCheckStatus: status})
|
||||
}
|
||||
|
||||
// CountDriftDomains returns the current number of domains system-wide whose
|
||||
// last check status is "drift". This is a global count (not per-project) —
|
||||
// it backs the dns_ar_drift_domains gauge, which is a system-level metric.
|
||||
func (s *Store) CountDriftDomains(ctx context.Context) (int, error) {
|
||||
n, err := s.q.CountDriftDomains(ctx)
|
||||
return int(n), err
|
||||
}
|
||||
|
||||
// User and Project are provider-neutral domain structs for the auth/tenant
|
||||
// layer (Фаза 2), mirroring the Account/Template/Domain wrappers above so
|
||||
// callers never need to import internal/store/db directly.
|
||||
|
||||
Reference in New Issue
Block a user