From 04d3f85e405a3da609623eeade2a2c2fec5d360d Mon Sep 17 00:00:00 2001
From: Jack Greenlee <greenljk@mail.uc.edu>
Date: Fri, 16 Aug 2024 17:10:50 -0400
Subject: [PATCH] tidy logs on metrics tab

https://github.com/e-mission/e-mission-phone/pull/1165
---
 www/js/components/Chart.tsx            |  6 ------
 www/js/metrics/CarbonFootprintCard.tsx | 10 +++++-----
 www/js/metrics/CarbonTextCard.tsx      | 10 +++++-----
 www/js/metrics/MetricsTab.tsx          |  1 -
 4 files changed, 10 insertions(+), 17 deletions(-)

diff --git a/www/js/components/Chart.tsx b/www/js/components/Chart.tsx
index e86ef794b..3a97ab697 100644
--- a/www/js/components/Chart.tsx
+++ b/www/js/components/Chart.tsx
@@ -146,9 +146,6 @@ const Chart = ({
                       ? {}
                       : {
                           callback: (value, i) => {
-                            logDebug(`Horizontal axis callback: i = ${i};
-                              chartDatasets = ${JSON.stringify(chartDatasets)};
-                              chartDatasets[0].data = ${JSON.stringify(chartDatasets[0].data)}`);
                             //account for different data possiblities
                             const label =
                               chartDatasets[0].data[i]?.y || chartDatasets[i].data[0]?.y;
@@ -185,9 +182,6 @@ const Chart = ({
                       ? {}
                       : {
                           callback: (value, i) => {
-                            logDebug(`Vertical axis callback: i = ${i}; 
-                              chartDatasets = ${JSON.stringify(chartDatasets)}; 
-                              chartDatasets[0].data = ${JSON.stringify(chartDatasets[0].data)}`);
                             //account for different data possiblities - one mode per week, one mode both weeks, mixed weeks
                             const label =
                               chartDatasets[0].data[i]?.x || chartDatasets[i].data[0]?.x;
diff --git a/www/js/metrics/CarbonFootprintCard.tsx b/www/js/metrics/CarbonFootprintCard.tsx
index 9624e10df..211abcc29 100644
--- a/www/js/metrics/CarbonFootprintCard.tsx
+++ b/www/js/metrics/CarbonFootprintCard.tsx
@@ -132,12 +132,12 @@ const CarbonFootprintCard = ({ userMetrics, aggMetrics }: Props) => {
       // Issue 422:
       // https://github.com/e-mission/e-mission-docs/issues/422
       let aggCarbonData: MetricsSummary[] = [];
-      for (let i in aggThisWeekSummary) {
-        aggCarbonData.push(aggThisWeekSummary[i]);
-        if (isNaN(aggCarbonData[i].values)) {
+      for (let summaryEntry of aggThisWeekSummary) {
+        aggCarbonData.push(summaryEntry);
+        if (isNaN(summaryEntry.values)) {
           logWarn(`WARNING in calculating groupCarbonRecords: value is NaN for mode 
-            ${aggCarbonData[i].key}, changing to 0`);
-          aggCarbonData[i].values = 0;
+            ${summaryEntry.key}, changing to 0`);
+          summaryEntry.values = 0;
         }
       }
 
diff --git a/www/js/metrics/CarbonTextCard.tsx b/www/js/metrics/CarbonTextCard.tsx
index ca9f50fdc..15234d530 100644
--- a/www/js/metrics/CarbonTextCard.tsx
+++ b/www/js/metrics/CarbonTextCard.tsx
@@ -108,12 +108,12 @@ const CarbonTextCard = ({ userMetrics, aggMetrics }: Props) => {
       // Issue 422:
       // https://github.com/e-mission/e-mission-docs/issues/422
       let aggCarbonData: MetricsSummary[] = [];
-      for (let i in aggThisWeekSummary) {
-        aggCarbonData.push(aggThisWeekSummary[i]);
-        if (isNaN(aggCarbonData[i].values)) {
+      for (let summaryEntry of aggThisWeekSummary) {
+        aggCarbonData.push(summaryEntry);
+        if (isNaN(summaryEntry.values)) {
           logWarn(`WARNING in calculating groupCarbonRecords: value is NaN for mode 
-            ${aggCarbonData[i].key}, changing to 0`);
-          aggCarbonData[i].values = 0;
+            ${summaryEntry.key}, changing to 0`);
+          summaryEntry.values = 0;
         }
       }
 
diff --git a/www/js/metrics/MetricsTab.tsx b/www/js/metrics/MetricsTab.tsx
index 3d4748f67..2c70d3a83 100644
--- a/www/js/metrics/MetricsTab.tsx
+++ b/www/js/metrics/MetricsTab.tsx
@@ -81,7 +81,6 @@ async function fetchAggMetrics(
   };
   return getAggregateData('result/metrics/yyyy_mm_dd', query, appConfig.server)
     .then((response) => {
-      logDebug('MetricsTab: received aggMetrics');
       console.debug('MetricsTab: received aggMetrics', response);
       return response as MetricsData;
     })