From ae62f43c2ef8fcf0959bedb8ad5c3d2ed34f68e4 Mon Sep 17 00:00:00 2001 From: Gabriele Granello <52770098+gabrielegranello@users.noreply.github.com> Date: Fri, 11 Oct 2024 11:21:36 +0100 Subject: [PATCH] fix prisma scheme (#113) Co-authored-by: Gabriele Granello --- app/data/hpiRepo.ts | 41 +++++++++++++++++++------------------- app/services/hpiService.ts | 4 ++-- prisma/schema.prisma | 2 +- 3 files changed, 23 insertions(+), 24 deletions(-) diff --git a/app/data/hpiRepo.ts b/app/data/hpiRepo.ts index 33cc949..16dad9f 100644 --- a/app/data/hpiRepo.ts +++ b/app/data/hpiRepo.ts @@ -1,26 +1,25 @@ import prisma from "./db"; const getHPIByITL3 = async (itl3: string): Promise => { - try { - const { - _avg: { hpi2020: averageHpi }, - } = await prisma.hPI.aggregate({ - where: { - itl3: { - endsWith: itl3, - }, - }, - _avg: { - hpi2020: true, - }, - }); - return averageHpi as number; - } catch (error) { - throw Error(`Data error: Unable to find hpi2020 for itl3 ${itl3}`); - } + try { + const { + _avg: { hpi2000: averageHpi }, + } = await prisma.hPI.aggregate({ + where: { + itl3: { + endsWith: itl3, + }, + }, + _avg: { + hpi2000: true, + }, + }); + return averageHpi as number; + } catch (error) { + throw Error(`Data error: Unable to find hpi2000 for itl3 ${itl3}`); + } }; -export const hpi2020Repo = { - getHPIByITL3, - }; - \ No newline at end of file +export const hpi2000Repo = { + getHPIByITL3, +}; diff --git a/app/services/hpiService.ts b/app/services/hpiService.ts index e6a7448..d7384e4 100644 --- a/app/services/hpiService.ts +++ b/app/services/hpiService.ts @@ -1,7 +1,7 @@ -import { hpi2020Repo } from "../data/hpiRepo"; +import { hpi2000Repo } from "../data/hpiRepo"; const getByITL3 = async (itl3: string) => { - return await hpi2020Repo.getHPIByITL3(itl3); + return await hpi2000Repo.getHPIByITL3(itl3); }; export const hpiService = { diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 3917419..a17837a 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -33,7 +33,7 @@ model HPI { region String? @db.VarChar(250) itl3 String? @db.VarChar(250) ladCode String? @map("ladcode") @db.VarChar(250) - hpi_2000 Float? + hpi2000 Float? @map("hpi_2000") @@map("hpi") }