feat: Added ID field to PublicService DTO, update fields in Service model, fix CalculateUptimePercent method, transform services to Public services in goroutines
This commit is contained in:
@@ -18,9 +18,9 @@ type Service struct {
|
||||
// Human-readable service name
|
||||
Name string `gorm:"size:255;not null" json:"name"`
|
||||
// Human-readable service description
|
||||
Description string `gorm:"size:255" json:"description"`
|
||||
PublicDescription string `gorm:"size:255" json:"public_description"`
|
||||
Public *bool `gorm:"default:false" json:"public"`
|
||||
Description *string `gorm:"size:255" json:"description"`
|
||||
PublicDescription *string `gorm:"size:255" json:"public_description"`
|
||||
Public *bool `gorm:"default:false" json:"public"`
|
||||
// Host to check, for example 192.168.1.44
|
||||
Host string `gorm:"size:255;not null" json:"host"`
|
||||
// Type for check, for now is TCP or HTTP
|
||||
@@ -67,7 +67,7 @@ func (s Service) CalculateUptimePercent() float64 {
|
||||
return uptime
|
||||
}
|
||||
|
||||
sla := 100 - (float64(len(s.Statuses)) / float64(countOfOkStatus))
|
||||
sla := 100 / (float64(len(s.Statuses)) / float64(countOfOkStatus))
|
||||
ratio := math.Pow(10, float64(2))
|
||||
uptime = math.Round(sla*ratio) / ratio
|
||||
|
||||
|
||||
Reference in New Issue
Block a user