Integrate local business workflow and SaaS redesign
This commit is contained in:
@@ -17,6 +17,7 @@ const blacklistType = v.union(
|
||||
v.literal("phone"),
|
||||
v.literal("company"),
|
||||
v.literal("google_place_id"),
|
||||
v.literal("source_business_id"),
|
||||
);
|
||||
|
||||
type BlacklistType =
|
||||
@@ -24,7 +25,8 @@ type BlacklistType =
|
||||
| "email"
|
||||
| "phone"
|
||||
| "company"
|
||||
| "google_place_id";
|
||||
| "google_place_id"
|
||||
| "source_business_id";
|
||||
|
||||
const BLACKLIST_APPLY_BATCH_SIZE = 100;
|
||||
const BLACKLIST_REVIEW_NOTE_PREFIX =
|
||||
@@ -51,6 +53,7 @@ type LeadMatchingFieldsPatch = Partial<
|
||||
| "normalizedCompanyName"
|
||||
| "normalizedAddress"
|
||||
| "normalizedGooglePlaceId"
|
||||
| "normalizedSourceBusinessId"
|
||||
>
|
||||
> & {
|
||||
updatedAt: number;
|
||||
@@ -138,6 +141,13 @@ function getLeadMatchQuery(
|
||||
.withIndex("by_normalizedGooglePlaceId", (q) =>
|
||||
q.eq("normalizedGooglePlaceId", normalizedValue),
|
||||
);
|
||||
case "source_business_id":
|
||||
return () =>
|
||||
ctx.db
|
||||
.query("leads")
|
||||
.withIndex("by_normalizedSourceBusinessId", (q) =>
|
||||
q.eq("normalizedSourceBusinessId", normalizedValue),
|
||||
);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
@@ -152,6 +162,9 @@ function buildLeadMatchingFieldsPatch(lead: Doc<"leads">) {
|
||||
const normalizedCompanyName = normalizeText(lead.companyName);
|
||||
const normalizedAddress = normalizeText(lead.address);
|
||||
const normalizedGooglePlaceId = normalizeDomain(lead.googlePlaceId);
|
||||
const normalizedSourceBusinessId = normalizeDomain(
|
||||
lead.sourceBusinessId ?? lead.googlePlaceId,
|
||||
);
|
||||
|
||||
if (!lead.normalizedEmail && normalizedEmail) {
|
||||
patch.normalizedEmail = normalizedEmail;
|
||||
@@ -168,6 +181,9 @@ function buildLeadMatchingFieldsPatch(lead: Doc<"leads">) {
|
||||
if (!lead.normalizedGooglePlaceId && normalizedGooglePlaceId) {
|
||||
patch.normalizedGooglePlaceId = normalizedGooglePlaceId;
|
||||
}
|
||||
if (!lead.normalizedSourceBusinessId && normalizedSourceBusinessId) {
|
||||
patch.normalizedSourceBusinessId = normalizedSourceBusinessId;
|
||||
}
|
||||
|
||||
return Object.keys(patch).length > 1 ? patch : null;
|
||||
}
|
||||
@@ -200,6 +216,7 @@ function normalizeBlacklistValue(type: BlacklistType, value: string) {
|
||||
return normalizePhone(trimmed);
|
||||
case "domain":
|
||||
case "google_place_id":
|
||||
case "source_business_id":
|
||||
return normalizeDomain(trimmed);
|
||||
case "company":
|
||||
return normalizeText(trimmed);
|
||||
|
||||
Reference in New Issue
Block a user