mirror of
https://github.com/smartyellow/status.git
synced 2025-01-18 05:27:58 +00:00
Re-added draftOutageEntries
This commit is contained in:
parent
9f28a8f30e
commit
354e735f10
36
index.js
36
index.js
@ -22,7 +22,7 @@ const icons = {
|
||||
const servicesNotifiedAboutOutage = new Set();
|
||||
let renderedDashboard = null;
|
||||
|
||||
async function processOutage({ outage, server, onDateUpdated }) {
|
||||
async function processOutage({ outage, server, settings, onDateUpdated }) {
|
||||
if (typeof onDateUpdated !== 'function') {
|
||||
onDateUpdated = () => null;
|
||||
}
|
||||
@ -34,6 +34,12 @@ async function processOutage({ outage, server, onDateUpdated }) {
|
||||
{ $set: { lastChecked: new Date() } }
|
||||
).then(() => onDateUpdated(id));
|
||||
|
||||
// Get service entry
|
||||
const service = await server
|
||||
.storage
|
||||
.store('smartyellow/webservice')
|
||||
.findOne({ id });
|
||||
|
||||
// Get last heartbeat
|
||||
const heartbeat = await server
|
||||
.storage
|
||||
@ -66,6 +72,34 @@ async function processOutage({ outage, server, onDateUpdated }) {
|
||||
server.error('status: could not save web service heartbeat');
|
||||
server.error(err);
|
||||
}
|
||||
|
||||
// Draft outage entry
|
||||
if (settings.draftOutageEntries) {
|
||||
try {
|
||||
server
|
||||
.storage
|
||||
.store('smartyellow/webserviceoutage')
|
||||
.insert({
|
||||
id: makeId(),
|
||||
name: {
|
||||
en: `[automatic] Outage for ${service.name.en}`,
|
||||
},
|
||||
state: 'concept',
|
||||
resolved: false,
|
||||
services: [ service.id ],
|
||||
tags: [ 'automatically created' ],
|
||||
notes: [ {
|
||||
date: new Date(),
|
||||
userId: 'system',
|
||||
text: `Automatically created outage. Reason: ${JSON.stringify(testResult, null, 2)}`,
|
||||
} ],
|
||||
});
|
||||
}
|
||||
catch (err) {
|
||||
server.warn('status: could not automatically draft outage entry');
|
||||
server.warn(err);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user