refactor(models): split Site into SiteConfig + SiteState
Site now embeds SiteConfig (22 persistent fields) and SiteState (11 ephemeral runtime fields). Field access unchanged via promotion — site.Name and site.Status still work. Store layer deals exclusively in SiteConfig — the DB never sees runtime state. Engine's liveState keeps full Site composites. UpdateSiteConfig reduced from 11-line field-by-field copy to `existing.SiteConfig = cfg`. RunCheck takes SiteConfig (only needs config fields). Checker is now statically prevented from reading/writing runtime state. Backup.Sites changed to []SiteConfig — exports no longer carry zero-valued runtime fields. Import backward-compatible (json ignores unknown fields).
This commit was merged in pull request #109.
This commit is contained in:
@@ -2,7 +2,7 @@ package models
|
||||
|
||||
import "time"
|
||||
|
||||
type Site struct {
|
||||
type SiteConfig struct {
|
||||
ID int
|
||||
Name string
|
||||
URL string
|
||||
@@ -26,7 +26,9 @@ type Site struct {
|
||||
IgnoreTLS bool
|
||||
Paused bool
|
||||
Regions string
|
||||
}
|
||||
|
||||
type SiteState struct {
|
||||
FailureCount int
|
||||
Status Status
|
||||
StatusCode int
|
||||
@@ -40,6 +42,11 @@ type Site struct {
|
||||
LastSuccessAt time.Time
|
||||
}
|
||||
|
||||
type Site struct {
|
||||
SiteConfig
|
||||
SiteState
|
||||
}
|
||||
|
||||
type StateChange struct {
|
||||
ID int
|
||||
SiteID int
|
||||
@@ -103,7 +110,7 @@ type MaintenanceWindow struct {
|
||||
}
|
||||
|
||||
type Backup struct {
|
||||
Sites []Site `json:"sites"`
|
||||
Sites []SiteConfig `json:"sites"`
|
||||
Alerts []AlertConfig `json:"alerts"`
|
||||
Users []User `json:"users"`
|
||||
MaintenanceWindows []MaintenanceWindow `json:"maintenance_windows,omitempty"`
|
||||
|
||||
Reference in New Issue
Block a user