Keep a typed main kind from being ranked as the catalog other kind, and store that catalog kind on the finished Rule.
This commit is contained in:
1 parent
4b90bce006
commit
3e0181e4de
7 files changed
+174
-48
No files matched your search
@@ -15,13 +15,14 @@ function trimmedLocation(raw: unknown): string | undefined {
|
||||
return trimmed.slice(0, LOCATION_MAX);
|
||||
}
|
||||
|
||||
/** Place and main group type stored on a finished Rule for launch counts. */
|
||||
/** Place and catalog group type stored on a finished Rule for launch counts. */
|
||||
export function publishedRuleAnalyticsFromState(state: CreateFlowState): {
|
||||
communityLocation?: string;
|
||||
orgType?: Kind;
|
||||
} {
|
||||
const communityLocation = trimmedLocation(state.communityLocation);
|
||||
const orgType = groupAnswersFromCreateFlowState(state).mainKind ?? undefined;
|
||||
const answers = groupAnswersFromCreateFlowState(state);
|
||||
const orgType = answers.mainKind ?? answers.otherKinds?.[0];
|
||||
return {
|
||||
...(communityLocation ? { communityLocation } : {}),
|
||||
...(orgType ? { orgType } : {}),
|
||||
@@ -37,8 +38,7 @@ export function publishedRuleAnalyticsFromDocument(document: unknown): {
|
||||
}
|
||||
const row = document as Record<string, unknown>;
|
||||
const communityLocation = trimmedLocation(row.communityLocation) ?? null;
|
||||
const orgTypeRaw =
|
||||
typeof row.orgType === "string" ? row.orgType.trim() : "";
|
||||
const orgTypeRaw = typeof row.orgType === "string" ? row.orgType.trim() : "";
|
||||
const orgType = isKind(orgTypeRaw) ? orgTypeRaw : null;
|
||||
return { communityLocation, orgType };
|
||||
}
|
||||
Reference in new issue
Block a user