103 lines
3.1 KiB
Go
103 lines
3.1 KiB
Go
package incident
|
|
|
|
import (
|
|
"github.com/lib/pq"
|
|
"time"
|
|
|
|
"gorm.io/gorm"
|
|
)
|
|
|
|
type IncidentStatus string
|
|
|
|
const (
|
|
Investigating IncidentStatus = "Investigating"
|
|
Identified = "Identified"
|
|
Monitoring = "Monitoring"
|
|
Resolved = "Resolved"
|
|
Duplicated = "Duplicated"
|
|
)
|
|
|
|
const (
|
|
Retrospective IncidentRole = "Retrospective"
|
|
Responder = "Responder"
|
|
ServiceOwner = "Service Owner"
|
|
)
|
|
|
|
type IncidentRole string
|
|
|
|
// IncidentEntity all the incident created will go in this table
|
|
type IncidentEntity struct {
|
|
gorm.Model
|
|
Title string `gorm:"column:title"`
|
|
Description string `gorm:"column:description"`
|
|
Status uint `gorm:"column:status"`
|
|
SeverityId uint `gorm:"column:severity_id"`
|
|
IncidentName string `gorm:"column:incident_name"`
|
|
SlackChannel string `gorm:"column:slack_channel"`
|
|
DetectionTime *time.Time `gorm:"column:detection_time"`
|
|
StartTime time.Time `gorm:"column:start_time"`
|
|
EndTime *time.Time `gorm:"column:end_time"`
|
|
TeamId uint `gorm:"column:team_id"`
|
|
JiraId *string `gorm:"column:jira_id"`
|
|
ConfluenceId *string `gorm:"column:confluence_id"`
|
|
SeverityTat time.Time `gorm:"column:severity_tat"`
|
|
RemindMeAt *time.Time `gorm:"column:remind_me_at"`
|
|
EnableReminder bool `gorm:"column:enable_reminder"`
|
|
CreatedBy string `gorm:"column:created_by"`
|
|
UpdatedBy string `gorm:"column:updated_by"`
|
|
}
|
|
|
|
func (IncidentEntity) TableName() string {
|
|
return "incident"
|
|
}
|
|
|
|
// IncidentRoleEntity this table will contain the role of the people assigned to the incident, mapping between incident
|
|
// and incident role entity will be one to many
|
|
type IncidentRoleEntity struct {
|
|
gorm.Model
|
|
IncidentId int `gorm:"column:incident_id"`
|
|
Role IncidentRole `gorm:"column:role"`
|
|
AssignedTo string `gorm:"column:assigned_to"`
|
|
AssignedBy string `gorm:"column:assigned_by"`
|
|
}
|
|
|
|
func (IncidentRoleEntity) TableName() string {
|
|
return "incident_role"
|
|
}
|
|
|
|
// IncidentChannelEntity contains the channels where the incident is being tracked
|
|
type IncidentChannelEntity struct {
|
|
gorm.Model
|
|
IncidentId uint `gorm:"column:incident_id"`
|
|
SlackChannel string `gorm:"column:slack_channel"`
|
|
MessageTimeStamp string `gorm:"column:message_timestamp"`
|
|
}
|
|
|
|
func (IncidentChannelEntity) TableName() string {
|
|
return "incident_channel"
|
|
}
|
|
|
|
// IncidentStatusEntity contains the possible incident statuses
|
|
type IncidentStatusEntity struct {
|
|
gorm.Model
|
|
Name string `gorm:"column:name"`
|
|
Description string `gorm:"column:description"`
|
|
IsTerminalStatus bool `gorm:"column:is_terminal_status"`
|
|
}
|
|
|
|
func (IncidentStatusEntity) TableName() string {
|
|
return "incident_status"
|
|
}
|
|
|
|
type IncidentTagEntity struct {
|
|
gorm.Model
|
|
IncidentId uint `gorm:"column:incident_id"`
|
|
TagId uint `gorm:"column:tag_id"`
|
|
TagValueIds pq.Int32Array `gorm:"column:tag_value_ids;type:integer[]"`
|
|
FreeTextValue *string `gorm:"column:free_text_value"`
|
|
}
|
|
|
|
func (IncidentTagEntity) TableName() string {
|
|
return "incident_tag"
|
|
}
|