Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions www/js/metrics/CarbonFootprintCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,14 @@ 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)) {
let aggCarbonData: MetricsSummary[] = aggThisWeekSummary.map((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;
}
}
return summaryEntry;
});

let groupRecords: { label: string; x: number | string; y: number | string }[] = [];

Expand Down
13 changes: 6 additions & 7 deletions www/js/metrics/CarbonTextCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,14 @@ 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)) {
let aggCarbonData: MetricsSummary[] = aggThisWeekSummary.map((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;
}
}
return summaryEntry;
});

let groupText: { label: string; value: string }[] = [];

Expand Down