-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
S3 document audit enhancements (#2849)
* add dedup func * fetch associated contract or rate * return the right thing * return contract or rate * simplify this * fixes * use existing * store funcs * find rate rev and contract * fix parser * debug * debugs * error return and log * add revisions * better parsing * add missing data * don't include contract * no safe parse * fix up types * if we can't fetch, collect the errors * naming
- Loading branch information
1 parent
c24f8a7
commit c1aad4d
Showing
6 changed files
with
186 additions
and
6 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
27 changes: 27 additions & 0 deletions
27
services/app-api/src/postgres/contractAndRates/findContractRevision.ts
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import type { PrismaTransactionType } from '../prismaTypes' | ||
import { NotFoundError } from '../postgresErrors' | ||
import type { ContractRevisionTable } from '@prisma/client' | ||
|
||
async function findContractRevision( | ||
client: PrismaTransactionType, | ||
contractRevID: string | ||
): Promise<ContractRevisionTable | Error> { | ||
try { | ||
const contractRev = await client.contractRevisionTable.findUnique({ | ||
where: { | ||
id: contractRevID, | ||
}, | ||
}) | ||
|
||
if (!contractRev) { | ||
const err = `PRISMA ERROR: Cannot find contract revision with id: ${contractRevID}` | ||
return new NotFoundError(err) | ||
} | ||
return contractRev | ||
} catch (err) { | ||
console.error('PRISMA ERROR', err) | ||
return err | ||
} | ||
} | ||
|
||
export { findContractRevision } |
28 changes: 28 additions & 0 deletions
28
services/app-api/src/postgres/contractAndRates/findRateRevision.ts
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import type { PrismaTransactionType } from '../prismaTypes' | ||
import { NotFoundError } from '../postgresErrors' | ||
import type { RateRevisionTable } from '@prisma/client' | ||
|
||
async function findRateRevision( | ||
client: PrismaTransactionType, | ||
rateRevisionID: string | ||
): Promise<RateRevisionTable | Error> { | ||
try { | ||
const rateRevision = await client.rateRevisionTable.findUnique({ | ||
where: { | ||
id: rateRevisionID, | ||
}, | ||
}) | ||
|
||
if (!rateRevision) { | ||
const err = `PRISMA ERROR: Cannot find rate revision with id: ${rateRevisionID}` | ||
return new NotFoundError(err) | ||
} | ||
|
||
return rateRevision | ||
} catch (err) { | ||
console.error('PRISMA ERROR', err) | ||
return err | ||
} | ||
} | ||
|
||
export { findRateRevision } |
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