Skip to content

Commit

Permalink
Merge pull request #1050 from Open-Earth-Foundation/nina/bug/ON-2864/…
Browse files Browse the repository at this point in the history
…handleMissingData
  • Loading branch information
lemilonkh authored Jan 10, 2025
2 parents b8ea283 + 831c1ed commit 40f7009
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ export const getGrowthRatesFromOC = async (
const response = await fetch(URL);
logger.info(`${URL} Response Status: ${response.status}`);
const data = await response.json();
if (response.status !== 200) {
return undefined;
}
return {
...data,
growthRates: data.growth_rates,
Expand Down
2 changes: 1 addition & 1 deletion app/src/backend/ResultsService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { ActivityDataByScope, GroupedActivity } from "@/util/types";
import Decimal from "decimal.js";
import { bigIntToDecimal } from "@/util/big_int";
import createHttpError from "http-errors";
import { getGrowthRatesFromOC } from "./OpenClimateService";
import { getGrowthRatesFromOC } from "./GlobalAPIService";
import { Inventory } from "@/models/Inventory";

function multiplyBigIntByFraction(
Expand Down
4 changes: 2 additions & 2 deletions app/tests/api/emissions_forecast.jest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ describe.skip("Emissions Forecast API", () => {
});

it("should calculate projected emissions correctly", async () => {
jest.mock("@/backend/OpenClimateService", () => {
jest.mock("@/backend/GlobalAPIService", () => {
return {
getGrowthRatesFromOC: jest
.fn()
Expand All @@ -67,7 +67,7 @@ describe.skip("Emissions Forecast API", () => {
});

it("should handle empty growth factors", async () => {
jest.mock("@/backend/OpenClimateService", () => {
jest.mock("@/backend/GlobalAPIService", () => {
return {
getGrowthRatesFromOC: jest.fn().mockImplementation(() => undefined),
};
Expand Down
2 changes: 1 addition & 1 deletion app/tests/api/results.data.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { randomUUID } from "node:crypto";
import { GrowthRatesResponse } from "@/backend/OpenClimateService";
import { GrowthRatesResponse } from "@/backend/GlobalAPIService";

export const inventoryValueId = randomUUID();
export const inventoryValueId1 = randomUUID();
Expand Down

0 comments on commit 40f7009

Please sign in to comment.