In this code, the following variables are defined:
incidentReport: A DataTable holding data about the current incident
status: A string column holding the current status of the incident
incident: A string column holding the current log message for the incident
last_incident: A string column holding the latest date that the incident was reported
DaysSinceIncident: A DataTable holding data about the number of days since the latest incident was reported
// 1st attempt
if (rows[0].status === 'false') {
incidentReport['status'] = false;
incidentReport['incident'] = rows[0].log_message;
incidentReport['timestamp'] = rows[0].date.toLocaleDateString();
if (daysOffset === 0) {
incidentReport['daysSinceIncident'] = 0;
} else {
incidentReport['daysSinceIncident'] = daysSinceIncident.rows[0].dayssinceincident.days;
}
} else {
incidentReport['status'] = true;
incidentReport['incident'] = null;
incidentReport['daysSinceIncident'] = null;
}
// 2nd attempt
incidentReport['timestamp'] = rows[0].date.toLocaleDateString();
incidentReport['status'] = rows[0].status;
incidentReport['incident'] = rows[0].log_message;
incidentReport['last_incident'] = daysSinceIncident.rows[0].days_since_incident;
@awillis-dev