Skip to content

Commit

Permalink
use global carbon intensity for missing places
Browse files Browse the repository at this point in the history
  • Loading branch information
sumn2u committed Nov 25, 2023
1 parent 6955b75 commit b259fb9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/utils/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os from 'os';
import * as cpuData from '../data/cpu_power.json' assert { type: 'json' };
import * as globalEnergyData from '../data/global_energy_mix.json' assert { type: 'json' };
import * as carbonIntensityData from '../data/carbon_intesity_per_source.json' assert {type: 'json'};
import https from 'https';

// Function to make an asynchronous HTTP request to get geographic information based on the IP address
Expand Down Expand Up @@ -85,10 +86,10 @@ export const getTotalCpuWattage = () => {
if (tdpValue !== undefined) {
return tdpValue;
} else {
return "Not supported";
return "Misssing CPU information"; // ADD missing cpu information to cpu_power.json
}
} else {
return "No CPU information available";
return "No CPU information available"; // TODO Get global average CPU tdp
}
};

Expand All @@ -98,6 +99,6 @@ export const getCarbonUsage = (countryCode) => {
if(geoInfo){
return geoInfo.carbon_intensity;
} else {
return 475; // Global carbon intensity
return carbonIntensityData.world_average; // Global carbon intensity
}
}

0 comments on commit b259fb9

Please sign in to comment.