From 5f6b5c0fb7edd468ff7a09fe04db6fab0ed5567b Mon Sep 17 00:00:00 2001 From: zzhhaa Date: Fri, 13 Dec 2024 14:22:55 +0000 Subject: [PATCH] feat: update column names in gasBillRepo --- app/data/gasBillRepo.test.ts | 6 +++--- app/data/gasBillRepo.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/data/gasBillRepo.test.ts b/app/data/gasBillRepo.test.ts index ad31ba66..327d9e27 100644 --- a/app/data/gasBillRepo.test.ts +++ b/app/data/gasBillRepo.test.ts @@ -18,14 +18,14 @@ describe("gasBillRepo", () => { const mockGasBill = 150; // Example gas bill amount (prisma.gasBills.findFirstOrThrow as jest.Mock).mockResolvedValueOnce({ - bill: mockGasBill, + kwh_cost_pence: mockGasBill, }); const result = await gasBillRepo.getGasBillByITL3(itl); expect(result).toBe(mockGasBill); expect(prisma.gasBills.findFirstOrThrow).toHaveBeenCalledWith({ - where: { itl: { startsWith: itl.substring(0, 3) } }, - select: { bill: true }, + where: { itl1: { startsWith: itl.substring(0, 3) } }, + select: { kwh_cost_pence: true }, }); }); diff --git a/app/data/gasBillRepo.ts b/app/data/gasBillRepo.ts index 08253d54..21125ce3 100644 --- a/app/data/gasBillRepo.ts +++ b/app/data/gasBillRepo.ts @@ -2,14 +2,14 @@ import prisma from "./db"; const getGasBillByITL3 = async (itl: string): Promise => { try { - const { bill } = await prisma.gasBills.findFirstOrThrow({ + const { kwh_cost_pence } = await prisma.gasBills.findFirstOrThrow({ where: { - itl: { startsWith: itl.substring(0, 3) }, + itl1: { startsWith: itl.substring(0, 3) }, }, - select: { bill: true }, + select: { kwh_cost_pence: true }, }); - return bill as number; + return kwh_cost_pence; } catch (error) { throw Error(`Data error: Unable to find gas_bills_2020 for itl3 ${itl}`); }