Skip to content

Commit

Permalink
chore: map kwh_cost_pence to camelCase
Browse files Browse the repository at this point in the history
  • Loading branch information
zz-hh-aa committed Dec 18, 2024
1 parent 48cddce commit 28c4631
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 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({
kwh_cost_pence: mockGasBill,
kwhCostPence: mockGasBill,
});

const result = await gasBillRepo.getGasBillByITL3(itl);
expect(result).toBe(mockGasBill);
expect(prisma.gasBills.findFirstOrThrow).toHaveBeenCalledWith({
where: { itl1: { startsWith: itl.substring(0, 3) } },
select: { kwh_cost_pence: true },
select: { kwhCostPence: true },
});
});

Expand Down
6 changes: 3 additions & 3 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 { kwh_cost_pence } = await prisma.gasBills.findFirstOrThrow({
const { kwhCostPence } = await prisma.gasBills.findFirstOrThrow({
where: {
itl1: { startsWith: itl.substring(0, 3) },
},
select: { kwh_cost_pence: true },
select: { kwhCostPence: true },
});

return kwh_cost_pence;
return kwhCostPence;
} catch (error) {
throw Error(`Data error: Unable to find gas_bills_2020 for itl3 ${itl}`);
}
Expand Down
2 changes: 1 addition & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ model GasBills {
id Int @id
region String @map("region") @db.VarChar
itl1 String @db.VarChar
kwh_cost_pence Float
kwhCostPence Float @map("kwh_cost_pence")
@@map("gas_bills")
}

0 comments on commit 28c4631

Please sign in to comment.