statping/types/incidents/samples.go

92 lines
2.0 KiB
Go
Raw Normal View History

2020-03-04 10:29:00 +00:00
package incidents
2020-04-07 00:06:46 +00:00
import (
"github.com/statping/statping/utils"
"time"
)
2020-03-09 15:15:15 +00:00
func Samples() error {
2020-03-04 10:29:00 +00:00
incident1 := &Incident{
2020-04-07 11:53:32 +00:00
Title: "Github Issues",
Description: "There are new features for Statping, if you have any issues please visit the Github Repo.",
2020-04-09 23:53:36 +00:00
ServiceId: 4,
2020-03-04 10:29:00 +00:00
}
2020-03-09 15:15:15 +00:00
if err := incident1.Create(); err != nil {
return err
}
2020-03-04 10:29:00 +00:00
2020-04-07 00:06:46 +00:00
incident2 := &Incident{
Title: "Recent Downtime",
Description: "We've noticed an issue with authentications and we're looking into it now.",
2020-04-09 23:53:36 +00:00
ServiceId: 5,
2020-04-07 00:06:46 +00:00
}
if err := incident2.Create(); err != nil {
return err
}
t := utils.Now()
2020-03-04 10:29:00 +00:00
i1 := &IncidentUpdate{
2020-04-07 11:53:32 +00:00
IncidentId: incident1.Id,
Message: "Github seems be be having an issue right now.",
Type: "investigating",
2020-04-07 00:06:46 +00:00
CreatedAt: t.Add(-60 * time.Minute),
2020-03-04 10:29:00 +00:00
}
2020-03-09 15:15:15 +00:00
if err := i1.Create(); err != nil {
return err
}
2020-03-04 10:29:00 +00:00
i2 := &IncidentUpdate{
2020-04-07 11:53:32 +00:00
IncidentId: incident1.Id,
Message: "Problem is continuing and we are looking at the issue.",
Type: "update",
2020-04-07 00:06:46 +00:00
CreatedAt: t.Add(-30 * time.Minute),
2020-03-04 10:29:00 +00:00
}
2020-03-09 15:15:15 +00:00
if err := i2.Create(); err != nil {
return err
}
2020-03-04 10:29:00 +00:00
i3 := &IncidentUpdate{
2020-04-07 11:53:32 +00:00
IncidentId: incident1.Id,
2020-03-04 10:29:00 +00:00
Message: "Github is now back online and everything is working.",
Type: "Resolved",
2020-04-07 00:06:46 +00:00
CreatedAt: t.Add(-5 * time.Minute),
2020-03-04 10:29:00 +00:00
}
2020-03-09 15:15:15 +00:00
if err := i3.Create(); err != nil {
return err
}
2020-03-04 14:20:47 +00:00
u1 := &IncidentUpdate{
2020-04-07 11:53:32 +00:00
IncidentId: incident2.Id,
Message: "Github is acting odd, probably getting DDOS-ed by China.",
Type: "investigating",
2020-04-07 00:06:46 +00:00
CreatedAt: t.Add(-120 * time.Minute),
2020-03-04 14:20:47 +00:00
}
2020-03-09 15:15:15 +00:00
if err := u1.Create(); err != nil {
return err
}
2020-04-07 00:06:46 +00:00
u2 := &IncidentUpdate{
2020-04-07 11:53:32 +00:00
IncidentId: incident2.Id,
Message: "Still seems to be an issue",
Type: "update",
2020-04-07 00:06:46 +00:00
CreatedAt: t.Add(-60 * time.Minute),
}
2020-04-07 11:53:32 +00:00
2020-04-07 00:06:46 +00:00
if err := u2.Create(); err != nil {
return err
}
2020-04-07 11:53:32 +00:00
u3 := &IncidentUpdate{
IncidentId: incident2.Id,
Message: "Github is now back online and everything is working.",
Type: "resolved",
CreatedAt: t.Add(-5 * time.Minute),
}
if err := u3.Create(); err != nil {
return err
}
2020-03-09 15:15:15 +00:00
return nil
2020-03-04 10:29:00 +00:00
}