package models import ( "time" "rocketgit.ru/rsmon/worker/app/models/concerns" ) // CheckRegionResult stores check results from distributed workers by region type CheckRegionResult struct { concerns.Model CheckID int64 `gorm:"index;not null" json:"check_id"` Check *Check `gorm:"foreignKey:CheckID" json:"check,omitempty"` RegionCode string `gorm:"size:20;not null;index" json:"region_code"` Region *Region `gorm:"foreignKey:RegionCode;references:Code" json:"region,omitempty"` WorkerNodeID *int64 `gorm:"index" json:"worker_node_id"` WorkerNode *WorkerNode `gorm:"foreignKey:WorkerNodeID" json:"worker_node,omitempty"` ExecutedAt time.Time `gorm:"not null" json:"executed_at"` State string `gorm:"size:10;not null" json:"state"` DurationMs int64 `json:"duration_ms"` Error *string `json:"error"` // AggregatedAt is set by app/models/check_aggregator.go once a row has // been folded into a Check.State decision. NULL means "still waiting // for the aggregator"; non-NULL means "this row has already been // counted in a quorum decision and must not be re-counted". The // column is indexed (see check_aggregator.go index helper) so the // per-tick SELECT that finds unaggregated rows is O(matching rows) // rather than scanning the whole table. AggregatedAt *time.Time `gorm:"index" json:"aggregated_at,omitempty"` concerns.Timestamped }