-
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.
Merge branch 'main' into gg/unit-test-expansion
- Loading branch information
Showing
11 changed files
with
322 additions
and
155 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,30 @@ | ||
import prisma from "./db"; | ||
|
||
const getRentByITL3 = async (itl3: string): Promise<number | null> => { | ||
try { | ||
const result = await prisma.rent.aggregate({ | ||
where: { | ||
itl3: { equals: itl3 }, | ||
}, | ||
_avg: { | ||
monthlyMeanRent: true, | ||
}, | ||
}); | ||
const getRentByITL3 = async (itl3: string): Promise<number> => { | ||
try { | ||
const result = await prisma.rent.aggregate({ | ||
where: { | ||
itl3: { equals: itl3 }, | ||
}, | ||
_avg: { | ||
monthlyMeanRent: true, | ||
}, | ||
}); | ||
|
||
const monthlyMeanRent = result._avg.monthlyMeanRent; | ||
const monthlyMeanRent = result._avg.monthlyMeanRent; | ||
|
||
return monthlyMeanRent; | ||
} catch (error) { | ||
throw new Error(`Data error: Unable to find monthlyMeanRent for itl3 ${itl3}`); | ||
if (monthlyMeanRent === null) { | ||
throw new Error(`No monthlyMeanRent found for itl3 ${itl3}`); | ||
} | ||
|
||
return monthlyMeanRent; | ||
} catch (error) { | ||
throw new Error( | ||
`Data error: Unable to find monthlyMeanRent for itl3 ${itl3}` | ||
); | ||
} | ||
}; | ||
|
||
export const rentRepo = { | ||
getRentByITL3, | ||
getRentByITL3, | ||
}; |
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
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
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
Oops, something went wrong.