-
Notifications
You must be signed in to change notification settings - Fork 245
[comp] Production Deploy #1975
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[comp] Production Deploy #1975
Changes from 5 commits
c4eba59
921c442
412bb92
d3f424e
002bb3e
f63164e
47b8787
0b6cf11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -82,6 +82,20 @@ export class VendorsService { | |
| id, | ||
| organizationId, | ||
| }, | ||
| include: { | ||
| assignee: { | ||
| include: { | ||
| user: { | ||
| select: { | ||
| id: true, | ||
| name: true, | ||
| email: true, | ||
| image: true, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }, | ||
| }); | ||
|
|
||
| if (!vendor) { | ||
|
|
@@ -90,8 +104,51 @@ export class VendorsService { | |
| ); | ||
| } | ||
|
|
||
| // Fetch risk assessment from GlobalVendors if vendor has a website | ||
| const domain = extractDomain(vendor.website); | ||
| let globalVendorData: { | ||
| website: string; | ||
| riskAssessmentData: Prisma.JsonValue; | ||
| riskAssessmentVersion: string | null; | ||
| riskAssessmentUpdatedAt: Date | null; | ||
| } | null = null; | ||
|
|
||
| if (domain) { | ||
| const duplicates = await db.globalVendors.findMany({ | ||
| where: { | ||
| website: { | ||
| contains: domain, | ||
| }, | ||
| }, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Substring domain match may return wrong vendor dataThe |
||
| select: { | ||
| website: true, | ||
| riskAssessmentData: true, | ||
| riskAssessmentVersion: true, | ||
| riskAssessmentUpdatedAt: true, | ||
| }, | ||
| orderBy: [ | ||
| { riskAssessmentUpdatedAt: 'desc' }, | ||
| { createdAt: 'desc' }, | ||
| ], | ||
| }); | ||
|
|
||
| // Prefer record WITH risk assessment data (most recent) | ||
| globalVendorData = | ||
| duplicates.find((gv) => gv.riskAssessmentData !== null) ?? | ||
| duplicates[0] ?? | ||
| null; | ||
| } | ||
|
|
||
| // Merge GlobalVendors risk assessment data into response | ||
| const vendorWithRiskAssessment = { | ||
| ...vendor, | ||
| riskAssessmentData: globalVendorData?.riskAssessmentData ?? null, | ||
| riskAssessmentVersion: globalVendorData?.riskAssessmentVersion ?? null, | ||
| riskAssessmentUpdatedAt: globalVendorData?.riskAssessmentUpdatedAt ?? null, | ||
| }; | ||
|
|
||
| this.logger.log(`Retrieved vendor: ${vendor.name} (${id})`); | ||
| return vendor; | ||
| return vendorWithRiskAssessment; | ||
| } catch (error) { | ||
| if (error instanceof NotFoundException) { | ||
| throw error; | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.