Skip to content
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

MNTOR-3893 - Fix qa custom broker tool #5647

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
Open

MNTOR-3893 - Fix qa custom broker tool #5647

wants to merge 13 commits into from

Conversation

codemist
Copy link
Collaborator

References:

Jira: MNTOR-3893
Figma:

Description

Screenshot (if applicable)

Not applicable.

How to test

Checklist (Definition of Done)

  • Localization strings (if needed) have been added.
  • Commits in this PR are minimal and have descriptive commit messages.
  • I've added or updated the relevant sections in readme and/or code comments
  • I've added a unit test to test for potential regressions of this bug.
  • If this PR implements a feature flag or experimentation, I've checked that it still works with the flag both on, and with the flag off.
  • If this PR implements a feature flag or experimentation, the Ship Behind Feature Flag status in Jira has been set
  • Product Owner accepted the User Story (demo of functionality completed) or waived the privilege.
  • All acceptance criteria are met.
  • Jira ticket has been updated (if needed) to match changes made during the development process.
  • Jira ticket has been updated (if needed) with suggestions for QA when this PR is deployed to stage.

Copy link

@codemist codemist requested a review from mansaj February 21, 2025 04:20
@@ -106,11 +107,21 @@ export default async function DashboardPage(props: Props) {
return redirect("/user/welcome");
}

const latestScan = await getScanResultsWithBroker(
const enabledFeatureFlags = await getEnabledFeatureFlags({
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should wrap the logic here with an if check (safer):

if (not prod && feature flag enabled for this email) {
  scanResults = getMock()
} else {
  scanResults = getReal()
}

This way we 1) only go to the db once 2) logic seems clearer to read

@@ -491,6 +489,45 @@ async function getScanResultsWithBroker(
return { scan: scan ?? null, results: scanResults } as LatestOnerepScanData;
}

async function getMockedScanResults(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the naming better with getMockedScanResults with getMockedScanResultsWithBrokers? This returns the aggregated results I believe

const res = (await knex("qa_custom_brokers")
.where("onerep_profile_id", onerep_profile_id)
.select("*")) as QaBrokerData[];
async function getAllQaCustomBrokers(): Promise<
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should rename this to something like scanResultWithBrokers.. also for the UI, it might be confusing to see the word "brokers" and see scan results attributes

@@ -47,24 +47,13 @@ function duplicateObj(obj: mockInputs, n: string | undefined) {
return Array.from({ length: howMany }, () => obj);
}

export async function GET(req: NextRequest) {
export async function GET() {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed the need for profileId here since it's not being used.

Comment on lines +118 to +120
const scanResults = useMockedScans
? await getMockedScanResults(profileId)
: await getScanResultsWithBroker(profileId, hasPremium(session.user));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should only load one db at a time.

@codemist codemist requested a review from mansaj February 21, 2025 20:59
Copy link
Collaborator

@mansaj mansaj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants