Show incident report (without filtering for now)
This commit is contained in:
@@ -30,34 +30,39 @@ const uploadDoorLockData = (req, res) => {
|
||||
unknownMembers.push(...parserResult.unknownMembers);
|
||||
});
|
||||
|
||||
const asyncJobs = [];
|
||||
const asyncWriteJobs = [];
|
||||
|
||||
fetchAllBookings()
|
||||
.then((bookingEntries) => {
|
||||
bookingEntries.forEach((bookingEntry) => asyncJobs.push(writeBookingReservation(bookingEntry)));
|
||||
})
|
||||
.catch((error) => {
|
||||
res.status(500).send(error);
|
||||
return;
|
||||
});
|
||||
parsedData.forEach((entry) => asyncWriteJobs.push(writeDoorLockEvent(entry)));
|
||||
|
||||
parsedData.forEach((entry) => asyncJobs.push(writeDoorLockEvent(entry)));
|
||||
|
||||
Promise.all(asyncJobs)
|
||||
Promise.all(asyncWriteJobs)
|
||||
.then(() => {
|
||||
res.json({
|
||||
parsedData,
|
||||
parserErrors,
|
||||
unknownMembers
|
||||
});
|
||||
|
||||
calculateDoorLockCharges();
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(`${integrationServiceErrors.FAILED_TO_SAVE_BOOKINGS} or ${integrationServiceErrors.FAILED_TO_SAVE_DOOR_LOCK_ENTRIES}`)
|
||||
console.log(integrationServiceErrors.FAILED_TO_SAVE_DOOR_LOCK_ENTRIES);
|
||||
console.log(error);
|
||||
res.status(500).send(integrationServiceErrors.FAILED_TO_SAVE_DATA_GENERIC);
|
||||
});
|
||||
|
||||
fetchAllBookings()
|
||||
.then((bookingEntries) => {
|
||||
const asyncJobs = [];
|
||||
bookingEntries.forEach((bookingEntry) => asyncJobs.push(writeBookingReservation(bookingEntry)));
|
||||
|
||||
Promise.all(asyncJobs)
|
||||
.then(() => {
|
||||
calculateDoorLockCharges();
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(integrationServiceErrors.FAILED_TO_SAVE_BOOKINGS);
|
||||
console.log(error);
|
||||
return;
|
||||
});
|
||||
})
|
||||
.catch((error) => {
|
||||
res.status(500).send(error);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { getMappingsFromDatabase, fetchOffices, fetchResources, saveNewMappingToDatabase } = require('../services/officeRnD/resources');
|
||||
const { getAllDoorLockIncidents } = require('../services/integration/reports');
|
||||
|
||||
const getKnownOfficeResourceMappings = (req, res) => {
|
||||
const dataToFetch = [getMappingsFromDatabase(), fetchOffices(), fetchResources() ];
|
||||
@@ -31,7 +32,29 @@ const addNewMapping = (req, res) => {
|
||||
}
|
||||
};
|
||||
|
||||
const getAllIncidents = (req, res) => {
|
||||
getAllDoorLockIncidents()
|
||||
.then((incidents) => {
|
||||
res.send(incidents);
|
||||
})
|
||||
.catch((error) => {
|
||||
console.log(error);
|
||||
res.send([]);
|
||||
});
|
||||
};
|
||||
|
||||
const getUnlockedIncidents = (req, res) => {
|
||||
|
||||
};
|
||||
|
||||
const getUnscheduledIncidents = (req, res) => {
|
||||
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
getKnownOfficeResourceMappings,
|
||||
addNewMapping,
|
||||
getAllIncidents,
|
||||
getUnscheduledIncidents,
|
||||
getUnlockedIncidents,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user