From 05f9d5287d998f95341bd604a66ec97538c6cc48 Mon Sep 17 00:00:00 2001
From: Pithon Kabiro <pithon.kabiro@hft-stuttgart.de>
Date: Thu, 24 Jun 2021 16:15:24 +0200
Subject: [PATCH] Edit function that maps buildings to datastreams

Fix typo in one of the property names. Perform minor tweaks to function.
---
 public/js/appChart.js | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/public/js/appChart.js b/public/js/appChart.js
index 86ff90a..0034587 100644
--- a/public/js/appChart.js
+++ b/public/js/appChart.js
@@ -18,9 +18,6 @@ export const getDatastreamIdFromBuildingNumber = function (
   phenomenon,
   samplingRate
 ) {
-  // Ensure that building number passed here is numeric
-  if (!Number.isInteger(buildingNumber)) return;
-
   const buildingToDatastreamMapping = {
     101: {
       vl: { "15min": "69", "60min": "75" },
@@ -46,7 +43,7 @@ export const getDatastreamIdFromBuildingNumber = function (
       energy: { "15min": "119", "60min": "125" },
       energy_verb: { "15min": "131", "60min": "137" },
     },
-    "112_118": {
+    "112, 118": {
       vl: { "15min": "72", "60min": "78" },
       rl: { "15min": "84", "60min": "90" },
       flow: { "15min": "96", "60min": "102" },
@@ -72,6 +69,11 @@ export const getDatastreamIdFromBuildingNumber = function (
     },
   };
 
+  if (!buildingNumber) return;
+
+  // check if building is contained in mapping object
+  if (!(buildingNumber in buildingToDatastreamMapping)) return;
+
   const datastreamIdMatched = Number(
     buildingToDatastreamMapping[buildingNumber][phenomenon][samplingRate]
   );
-- 
GitLab