Fix QX task impact registry initialization

This commit is contained in:
Sai-karthik
2026-07-07 20:10:16 +00:00
parent 6d996882bf
commit 4b0bf4379f

View File

@@ -187,18 +187,18 @@ type QxKpiWeight = {
dims: QxDimension[];
};
const QX_PROFILE_BY_ICP: Record<CuratorIcpId, keyof typeof QX_PROFILE_KPI_WEIGHTS> = {
student_recent_grad: "Student",
intern: "Student",
fresher_early_professional: "Student",
experienced_professional: "Prof_Leadership",
freelancer: "Prof_Creative",
founder: "Entrepreneur",
enterprise: "Prof_Leadership",
};
type QxProfile = "Student" | "Prof_Leadership" | "Prof_Creative" | "Entrepreneur";
const QX_PROFILE_KPI_WEIGHTS = {
Student: {
function qxProfileForIcp(icpId: CuratorIcpId): QxProfile {
if (icpId === "experienced_professional" || icpId === "enterprise") return "Prof_Leadership";
if (icpId === "freelancer") return "Prof_Creative";
if (icpId === "founder") return "Entrepreneur";
return "Student";
}
function qxProfileKpiWeights(profile: QxProfile): Record<number, QxKpiWeight> {
const weights: Record<QxProfile, Record<number, QxKpiWeight>> = {
Student: {
1: { weight: 2.84, dims: ["SQ"] },
4: { weight: 1.41, dims: [] },
10: { weight: 3.78, dims: [] },
@@ -213,7 +213,7 @@ const QX_PROFILE_KPI_WEIGHTS = {
39: { weight: 1.89, dims: ["IQ", "EQ", "SQ"] },
41: { weight: 1.89, dims: ["EQ", "SQ"] },
},
Prof_Leadership: {
Prof_Leadership: {
1: { weight: 3.34, dims: ["SQ"] },
5: { weight: 2.5, dims: ["IQ"] },
6: { weight: 3.34, dims: ["SQ"] },
@@ -229,7 +229,7 @@ const QX_PROFILE_KPI_WEIGHTS = {
39: { weight: 1.67, dims: ["IQ", "EQ", "SQ"] },
41: { weight: 2.08, dims: ["EQ", "SQ"] },
},
Prof_Creative: {
Prof_Creative: {
1: { weight: 2.58, dims: ["SQ"] },
4: { weight: 4.27, dims: [] },
5: { weight: 3.44, dims: ["IQ"] },
@@ -246,7 +246,7 @@ const QX_PROFILE_KPI_WEIGHTS = {
39: { weight: 1.72, dims: ["IQ", "EQ", "SQ"] },
41: { weight: 1.72, dims: ["EQ", "SQ"] },
},
Entrepreneur: {
Entrepreneur: {
1: { weight: 2.05, dims: ["SQ"] },
4: { weight: 2.05, dims: [] },
5: { weight: 2.05, dims: ["IQ"] },
@@ -263,7 +263,9 @@ const QX_PROFILE_KPI_WEIGHTS = {
39: { weight: 1.37, dims: ["IQ", "EQ", "SQ"] },
41: { weight: 1.37, dims: ["EQ", "SQ"] },
},
} satisfies Record<string, Record<number, QxKpiWeight>>;
};
return weights[profile];
}
const FALLBACK_DIMS_BY_SERVICE: Partial<Record<CuratorServiceId, QxDimension[]>> = {
"social-branding-service": ["SQ"],
@@ -314,8 +316,7 @@ function qxKpiIdForTask(task: StaticTaskRef): number {
}
function qxRawWeightForTask(icpId: CuratorIcpId, task: StaticTaskRef): number {
const profile = QX_PROFILE_BY_ICP[icpId];
const kpiWeights: Record<number, QxKpiWeight> = QX_PROFILE_KPI_WEIGHTS[profile];
const kpiWeights = qxProfileKpiWeights(qxProfileForIcp(icpId));
const kpi = kpiWeights[qxKpiIdForTask(task)];
const dims = kpi?.dims.length ? kpi.dims : FALLBACK_DIMS_BY_SERVICE[task.serviceId] ?? ["IQ"];
return kpi?.weight ?? dims.length;