-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Gabriele Granello <[email protected]>
- Loading branch information
1 parent
8f388fe
commit ae62f43
Showing
3 changed files
with
23 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
import prisma from "./db"; | ||
|
||
const getHPIByITL3 = async (itl3: string): Promise<number> => { | ||
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, | ||
}; | ||
|
||
export const hpi2000Repo = { | ||
getHPIByITL3, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters