Skip to content

Commit

Permalink
feat: update column names in gasBillRepo
Browse files Browse the repository at this point in the history
  • Loading branch information
zz-hh-aa committed Dec 13, 2024
1 parent 461fb35 commit 5f6b5c0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions app/data/gasBillRepo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
});
});

Expand Down
8 changes: 4 additions & 4 deletions app/data/gasBillRepo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import prisma from "./db";

const getGasBillByITL3 = async (itl: string): Promise<number> => {
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}`);
}
Expand Down

0 comments on commit 5f6b5c0

Please sign in to comment.