Get rid of partial param loading mechanism

Simplify device loading for better performance in most case, and the
potential for further optimizations to follow.
This commit is contained in:
Zaid Abdulla committed 2019-06-05 00:17:36 -07:00
1 parent f4c9321d4d
commit c5553d95c5
4 files changed
+112 -449

No files matched your search

+16
View File
@@ -1350,6 +1350,22 @@ async function listenerAsync(
}
}
const parameters = await db.fetchDevice(
_sessionContext.deviceId,
_sessionContext.timestamp
);
if (parameters) {
for (const p of parameters) {
const path = _sessionContext.deviceData.paths.add(p[0]);
_sessionContext.deviceData.timestamps.set(path, p[1], 0);
if (p[2]) _sessionContext.deviceData.attributes.set(path, p[2], 0);
}
} else {
// Device not available in database, mark as new
_sessionContext.new = true;
}
const authenticated = await authenticate(_sessionContext, bodyStr);
if (!authenticated) return responseUnauthorized(_sessionContext);