diff options
| author | zwlucas <lucas.fariamo08@gmail.com> | 2026-05-29 20:41:33 +0000 |
|---|---|---|
| committer | zwlucas <lucas.fariamo08@gmail.com> | 2026-05-29 20:41:33 +0000 |
| commit | 9218d22954d61296a32c49373ab0f17f0be59cfe (patch) | |
| tree | 595b94ce7c2b5eed9760f79e7781653d6b554d18 /backend/internal/store/postgres.go | |
| parent | d186a989b6808ff39fcd43a9f0b478aebc4aa346 (diff) | |
| download | yaum-9218d22954d61296a32c49373ab0f17f0be59cfe.tar.gz yaum-9218d22954d61296a32c49373ab0f17f0be59cfe.zip | |
feat: add SSL info tracking and server metrics collection
Signed-off-by: zwlucas <lucas.fariamo08@gmail.com>
Diffstat (limited to 'backend/internal/store/postgres.go')
| -rw-r--r-- | backend/internal/store/postgres.go | 28 |
1 files changed, 28 insertions, 0 deletions
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 +} |