snapshot migration phase 5

This commit is contained in:
DeSqBlocki
2026-08-27 19:34:16 +02:00
parent 42fc848f8c
commit 9710fc65bf
2 changed files with 518 additions and 4 deletions
+166
View File
@@ -896,6 +896,172 @@ async function auditProfileData(
continue;
}
/*
* ----------------------------------------------------
* EVENT ACHIEVEMENTS
* ----------------------------------------------------
*/
if (
definition.measure ===
"event"
) {
if (
!definition.eventType ||
typeof definition.eventType !==
"string"
) {
issues.push(
`${definition.achievementId}: event achievement has no eventType.`
);
}
if (
!Array.isArray(
definition.eventConditions
)
||
definition.eventConditions.length ===
0
) {
issues.push(
`${definition.achievementId}: event achievement has no eventConditions.`
);
continue;
}
const validEventOperators = [
"eq",
"neq",
"gt",
"gte",
"lt",
"lte",
"in",
"not_in",
"truthy",
"falsy"
];
for (
const [
index,
condition
]
of definition
.eventConditions
.entries()
) {
if (
!condition ||
typeof condition !==
"object"
) {
issues.push(
`${definition.achievementId}: event condition ${index + 1} is invalid.`
);
continue;
}
if (
!condition.field
) {
issues.push(
`${definition.achievementId}: event condition ${index + 1} has no field.`
);
}
const operator =
String(
condition.operator ??
"eq"
).toLowerCase();
if (
!validEventOperators.includes(
operator
)
) {
issues.push(
`${definition.achievementId}: event condition ${index + 1} has unknown operator "${operator}".`
);
}
if (
[
"eq",
"neq",
"gt",
"gte",
"lt",
"lte",
"in",
"not_in"
].includes(
operator
)
&&
condition.value ===
undefined
) {
issues.push(
`${definition.achievementId}: event condition ${index + 1} using "${operator}" is missing value.`
);
}
if (
[
"in",
"not_in"
].includes(
operator
)
&&
!Array.isArray(
condition.value
)
) {
issues.push(
`${definition.achievementId}: event condition ${index + 1} using "${operator}" requires an array value.`
);
}
if (
[
"gt",
"gte",
"lt",
"lte"
].includes(
operator
)
&&
!Number.isFinite(
Number(
condition.value
)
)
) {
issues.push(
`${definition.achievementId}: event condition ${index + 1} has a non-numeric comparison value.`
);
}
}
continue;
}
/*
* ----------------------------------------------------