Skip to content

Commit

Permalink
chore: status will default to 'scheduled' if the timestamp is in the …
Browse files Browse the repository at this point in the history
…future
  • Loading branch information
YogiPristiawan committed May 27, 2024
1 parent 4bce9d6 commit 5466372
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion backend/incident_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@ func (w *IncidentWriter) Write(ctx context.Context, incident Incident) error {
return fmt.Errorf("failed to parse timestamp: %w", err)
}

incidentStatus := incident.Status
if timestamp.After(time.Now()) {
incidentStatus = IncidentStatusScheduled
}

_, err = conn.ExecContext(ctx, "INSERT INTO incident_data (monitor_id, title, description, timestamp, severity, status, created_by) VALUES (?, ?, ?, ?, ?, ?, ?)",
incident.MonitorID,
incident.Title,
incident.Description,
timestamp,
incident.Severity,
incident.Status,
incidentStatus,
incident.CreatedBy,
)
if err != nil {
Expand Down

0 comments on commit 5466372

Please sign in to comment.