From 9218d22954d61296a32c49373ab0f17f0be59cfe Mon Sep 17 00:00:00 2001 From: zwlucas Date: Fri, 29 May 2026 17:41:33 -0300 Subject: feat: add SSL info tracking and server metrics collection Signed-off-by: zwlucas --- backend/internal/store/postgres.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'backend/internal/store/postgres.go') diff --git a/backend/internal/store/postgres.go b/backend/internal/store/postgres.go index 57fa258..fb07bdc 100644 --- a/backend/internal/store/postgres.go +++ b/backend/internal/store/postgres.go @@ -393,3 +393,31 @@ func (s *PostgresStore) DeleteMaintenance(id int) error { } return nil } + +func (s *PostgresStore) GetSSLInfo(serviceID int) (*model.SSLInfo, error) { + var info model.SSLInfo + err := s.pool.QueryRow(context.Background(), + `SELECT service_id, issuer, expires_at, days_remaining, checked_at FROM ssl_info WHERE service_id = $1`, + serviceID, + ).Scan(&info.ServiceID, &info.Issuer, &info.ExpiresAt, &info.DaysRemaining, &info.CheckedAt) + if err != nil { + if err == pgx.ErrNoRows { + return nil, nil + } + return nil, fmt.Errorf("get ssl info: %w", err) + } + return &info, nil +} + +func (s *PostgresStore) SaveSSLInfo(info model.SSLInfo) error { + _, err := s.pool.Exec(context.Background(), + `INSERT INTO ssl_info (service_id, issuer, expires_at, days_remaining, checked_at) + VALUES ($1, $2, $3, $4, $5) + ON CONFLICT (service_id) DO UPDATE SET issuer=$2, expires_at=$3, days_remaining=$4, checked_at=$5`, + info.ServiceID, info.Issuer, info.ExpiresAt, info.DaysRemaining, info.CheckedAt, + ) + if err != nil { + return fmt.Errorf("save ssl info: %w", err) + } + return nil +} -- cgit v1.2.3