Record the actor on assign, archive and unarchive (#35)
Assign logged only the assignee (user_id), archive/unarchive logged nothing. Migration 018 adds actor_user_id/actor_service_account_id to incident_events for 'assigned'; archive/unarchive now log archived/unarchived events with the caller via callerActorIDs. Timeline JSON gains actor_* fields; web timeline renders them. Service accounts are still not assignable.
This commit is contained in:
@@ -32,6 +32,8 @@ const (
|
||||
evAcknowledged = "acknowledged"
|
||||
evUnacknowledged = "unacknowledged"
|
||||
evAssigned = "assigned"
|
||||
evArchived = "archived"
|
||||
evUnarchived = "unarchived"
|
||||
evSnoozed = "snoozed"
|
||||
evUnsnoozed = "unsnoozed"
|
||||
evResolved = "resolved"
|
||||
@@ -143,6 +145,17 @@ func logEvent(ctx context.Context, q querier, incidentID int64, evType string, u
|
||||
return err
|
||||
}
|
||||
|
||||
// logAssignedEvent records an assignment: user_id is the assignee, and the
|
||||
// caller who performed it goes in the actor_* columns (migration 018), since
|
||||
// user_id cannot hold both.
|
||||
func logAssignedEvent(ctx context.Context, q querier, incidentID, assigneeID int64, actorUserID, actorServiceAccountID *int64) error {
|
||||
_, err := q.ExecContext(ctx, `
|
||||
INSERT INTO incident_events (incident_id, type, user_id, actor_user_id, actor_service_account_id, created_at)
|
||||
VALUES ($1, $2, $3, $4, $5, $6)`,
|
||||
incidentID, evAssigned, assigneeID, actorUserID, actorServiceAccountID, time.Now().Unix())
|
||||
return err
|
||||
}
|
||||
|
||||
// todayUTC is the schedule's day key. The schedule's smallest unit is one UTC day.
|
||||
func todayUTC() string {
|
||||
return time.Now().UTC().Format("2006-01-02")
|
||||
|
||||
Reference in New Issue
Block a user