Некоторые проверки не удались
CI / test (push) Successful in 2m5s
Docker / Build and publish worker image (push) Failing after 31s
49 строки
1.2 KiB
Go
49 строки
1.2 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
|
|
"rocketgit.ru/rsmon/worker/app/models/concerns"
|
|
)
|
|
|
|
// Message info about performed notification
|
|
type Message struct {
|
|
concerns.Model
|
|
|
|
NotificationID int64 `json:"notification_id"`
|
|
Notification *Notification `json:"notification,omitempty"`
|
|
|
|
ContactID int64 `gorm:"index;type:bigint REFERENCES contacts(id)" json:"contact_id"`
|
|
Contact *Contact `json:"contact,omitempty"`
|
|
|
|
// Events are for up/down messages
|
|
Events []Event `json:"events" gorm:"many2many:event_messages;"`
|
|
|
|
// Checks are for expires messages
|
|
CheckID *int64 `gorm:"index;type:bigint REFERENCES checks(id)" json:"check_id"`
|
|
Check *Check `json:"check,omitempty"`
|
|
|
|
Kind string `json:"kind"`
|
|
State string `json:"state"`
|
|
Error *string `json:"error"`
|
|
Response *string `json:"response"`
|
|
Tries int `json:"-"`
|
|
|
|
CreatedAt time.Time `json:"created_at"`
|
|
SentAt time.Time `json:"sent_at"`
|
|
}
|
|
|
|
// MessageScope provides functionality.
|
|
func MessageScope(q *gorm.DB) *gorm.DB {
|
|
return q.
|
|
Preload("Events").
|
|
Preload("Events.Checks").
|
|
Preload("Events.Monitor").
|
|
Preload("Notification").
|
|
Preload("Contact").
|
|
Preload("Check").
|
|
Preload("Check.Monitor")
|
|
}
|