Implement CSV download

This commit is contained in:
Zaid Abdulla committed 2018-12-26 00:22:07 -08:00
1 parent 24b047bd5e
commit a49cbc5e40
20 files changed
+391 -215

No files matched your search

+21
View File
@@ -337,6 +337,25 @@ function flattenDevice(device) {
return newDevice;
}
function flattenFault(fault) {
const f = Object.assign({}, fault);
if (f.timestamp) f.timestamp = +f.timestamp;
if (f.expiry) f.expiry = +f.expiry;
if (f.detail) {
for (let [k, v] of Object.entries(f.detail)) fault[`detail.${k}`] = v;
delete f.detail;
}
return f;
}
function flattenTask(task) {
let t = Object.assign({}, task);
t._id = "" + t._id;
if (t.timestamp) t.timestamp = +t.timestamp;
if (t.expiry) t.expiry = +t.expiry;
return t;
}
exports.processDeviceFilter = processDeviceFilter;
exports.processTasksFilter = processTasksFilter;
exports.processFaultsFilter = processFaultsFilter;
@@ -344,3 +363,5 @@ exports.filterToMongoQuery = filterToMongoQuery;
exports.processDeviceProjection = processDeviceProjection;
exports.processDeviceSort = processDeviceSort;
exports.flattenDevice = flattenDevice;
exports.flattenFault = flattenFault;
exports.flattenTask = flattenTask;