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

Add QA Custom broker data to broker scan results #5359

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 44 additions & 21 deletions src/db/tables/onerep_scans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,29 +411,52 @@ async function getScanResultsWithBrokerUnderMaintenance(
if (onerepProfileId === null) {
return null;
}
const qaToggles = await getQaToggleRow(onerepProfileId);
let showCustomBrokers = false;
let showRealBrokers = true;

let scanResults = await knex("onerep_scan_results as sr")
.select(
"sr.*",
"s.*",
"sr.status as scan_result_status", // rename to avoid collision
"db.status as broker_status", // rename to avoid collision
)
.innerJoin("onerep_scans as s", "sr.onerep_scan_id", "s.onerep_scan_id")
.where("s.onerep_profile_id", onerepProfileId)
.andWhere("sr.manually_resolved", "false")
.andWhereNot("sr.status", "removed")
.join("onerep_data_brokers as db", "sr.data_broker", "db.data_broker")
.orderBy("sr.onerep_scan_result_id");

scanResults = scanResults.filter(
(result) =>
result.broker_status === "removal_under_maintenance" ||
new Date().getTime() - new Date(result.updated_at).getTime() >
CONST_DAY_MILLISECONDS * 200,
);
if (qaToggles) {
showCustomBrokers = qaToggles.show_custom_brokers;
showRealBrokers = qaToggles.show_real_brokers;
}
const scan = await getLatestOnerepScan(onerepProfileId);

let results: OnerepScanResultRow[] = [];
Comment on lines +414 to +424
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The logic here for adding the QA custom broker results is similar to that of getLatestOnerepScanResults() in the same file.


if (showRealBrokers) {
let scanResults = await knex("onerep_scan_results as sr")
.select(
"sr.*",
"s.*",
"sr.status as scan_result_status", // rename to avoid collision
"db.status as broker_status", // rename to avoid collision
)
.innerJoin("onerep_scans as s", "sr.onerep_scan_id", "s.onerep_scan_id")
.where("s.onerep_profile_id", onerepProfileId)
.andWhere("sr.manually_resolved", "false")
.andWhereNot("sr.status", "removed")
.join("onerep_data_brokers as db", "sr.data_broker", "db.data_broker")
.orderBy("sr.onerep_scan_result_id");

scanResults = scanResults.filter(
(result) =>
result.broker_status === "removal_under_maintenance" ||
new Date().getTime() - new Date(result.updated_at).getTime() >
CONST_DAY_MILLISECONDS * 200,
);

results = scanResults;
}
// Fetch custom brokers if allowed
if (showCustomBrokers) {
const qaBrokers = await getQaCustomBrokers(
onerepProfileId,
scan?.onerep_scan_id,
);
results = [...results, ...qaBrokers];
}

return { results: scanResults } as LatestOnerepScanData;
return { results } as LatestOnerepScanData;
}

export {
Expand Down
Loading