|
|
|
@@ -16,7 +16,7 @@ INSERT INTO incidents (
|
|
|
|
|
) VALUES(
|
|
|
|
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
|
|
|
|
)
|
|
|
|
|
RETURNING id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, sub_category, sys_id
|
|
|
|
|
RETURNING id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, sub_category, sys_id, updated_at
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
type CreateIncidentParams struct {
|
|
|
|
@@ -65,6 +65,7 @@ func (q *Queries) CreateIncident(ctx context.Context, arg CreateIncidentParams)
|
|
|
|
|
&i.Category,
|
|
|
|
|
&i.SubCategory,
|
|
|
|
|
&i.SysID,
|
|
|
|
|
&i.UpdatedAt,
|
|
|
|
|
)
|
|
|
|
|
return i, err
|
|
|
|
|
}
|
|
|
|
@@ -157,7 +158,7 @@ func (q *Queries) CreateWorkNote(ctx context.Context, arg CreateWorkNoteParams)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getIncident = `-- name: GetIncident :one
|
|
|
|
|
SELECT id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, sub_category, sys_id from incidents
|
|
|
|
|
SELECT id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, sub_category, sys_id, updated_at from incidents
|
|
|
|
|
WHERE incident_number = ?1
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
@@ -179,12 +180,13 @@ func (q *Queries) GetIncident(ctx context.Context, incidentnumber sql.NullString
|
|
|
|
|
&i.Category,
|
|
|
|
|
&i.SubCategory,
|
|
|
|
|
&i.SysID,
|
|
|
|
|
&i.UpdatedAt,
|
|
|
|
|
)
|
|
|
|
|
return i, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getIncidentReport = `-- name: GetIncidentReport :many
|
|
|
|
|
SELECT incidents.id, incidents.external_id, incidents.created_at, incidents.incident_number, incidents.description, incidents.short_description, incidents.urgency, incidents.impact, incidents.state, incidents.assignment_group, incidents.assigned_to, incidents.category, incidents.sub_category, incidents.sys_id, IFNULL(GROUP_CONCAT(worknotes.note, '<br />'), ' ') AS all_notes
|
|
|
|
|
SELECT incidents.id, incidents.external_id, incidents.created_at, incidents.incident_number, incidents.description, incidents.short_description, incidents.urgency, incidents.impact, incidents.state, incidents.assignment_group, incidents.assigned_to, incidents.category, incidents.sub_category, incidents.sys_id, incidents.updated_at, IFNULL(GROUP_CONCAT(worknotes.note, '<br />'), ' ') AS all_notes
|
|
|
|
|
FROM incidents LEFT JOIN worknotes ON incidents.incident_number = worknotes.incident_number
|
|
|
|
|
GROUP BY incidents.id
|
|
|
|
|
`
|
|
|
|
@@ -204,6 +206,7 @@ type GetIncidentReportRow struct {
|
|
|
|
|
Category sql.NullString
|
|
|
|
|
SubCategory sql.NullString
|
|
|
|
|
SysID sql.NullString
|
|
|
|
|
UpdatedAt sql.NullTime
|
|
|
|
|
AllNotes interface{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -231,6 +234,7 @@ func (q *Queries) GetIncidentReport(ctx context.Context) ([]GetIncidentReportRow
|
|
|
|
|
&i.Category,
|
|
|
|
|
&i.SubCategory,
|
|
|
|
|
&i.SysID,
|
|
|
|
|
&i.UpdatedAt,
|
|
|
|
|
&i.AllNotes,
|
|
|
|
|
); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
@@ -280,7 +284,7 @@ func (q *Queries) GetIncidentWorkNotes(ctx context.Context, incidentnumber strin
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const listIncidents = `-- name: ListIncidents :many
|
|
|
|
|
SELECT id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, sub_category, sys_id FROM incidents
|
|
|
|
|
SELECT id, external_id, created_at, incident_number, description, short_description, urgency, impact, state, assignment_group, assigned_to, category, sub_category, sys_id, updated_at FROM incidents
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|
func (q *Queries) ListIncidents(ctx context.Context) ([]Incident, error) {
|
|
|
|
@@ -307,6 +311,7 @@ func (q *Queries) ListIncidents(ctx context.Context) ([]Incident, error) {
|
|
|
|
|
&i.Category,
|
|
|
|
|
&i.SubCategory,
|
|
|
|
|
&i.SysID,
|
|
|
|
|
&i.UpdatedAt,
|
|
|
|
|
); err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
@@ -408,7 +413,8 @@ SET
|
|
|
|
|
assignment_group = ?,
|
|
|
|
|
assigned_to = ?,
|
|
|
|
|
category = ?,
|
|
|
|
|
sub_category = ?
|
|
|
|
|
sub_category = ?,
|
|
|
|
|
updated_at = CURRENT_TIMESTAMP
|
|
|
|
|
WHERE incident_number = ?
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
@@ -477,7 +483,7 @@ func (q *Queries) UpdateIncidentNumberSysId(ctx context.Context, arg UpdateIncid
|
|
|
|
|
|
|
|
|
|
const updateIncidentState = `-- name: UpdateIncidentState :exec
|
|
|
|
|
UPDATE incidents
|
|
|
|
|
SET state = ?1
|
|
|
|
|
SET state = ?1, updated_at = CURRENT_TIMESTAMP
|
|
|
|
|
WHERE incident_number = ?2
|
|
|
|
|
`
|
|
|
|
|
|
|
|
|
|