Semaphore/db/Event.go
tom whiston 17fa7bb407 add gometalinter to tools and run it in circle.
extract some error checking and logging in places where linting needed or errors not checked
2018-04-05 21:24:19 +00:00

23 lines
844 B
Go

package db
import "time"
// Event represents information generated by ansible or api action captured to the database during execution
type Event struct {
ProjectID *int `db:"project_id" json:"project_id"`
ObjectID *int `db:"object_id" json:"object_id"`
ObjectType *string `db:"object_type" json:"object_type"`
Description *string `db:"description" json:"description"`
Created time.Time `db:"created" json:"created"`
ObjectName string `db:"-" json:"object_name"`
ProjectName *string `db:"project_name" json:"project_name"`
}
// Insert writes the event to the database
func (evt Event) Insert() error {
_, err := Mysql.Exec("insert into event set project_id=?, object_id=?, object_type=?, description=?, created=UTC_TIMESTAMP(6)", evt.ProjectID, evt.ObjectID, evt.ObjectType, evt.Description)
return err
}