Update "abs" to "absolute" for goal criteria.

This commit is contained in:
zkldi
2022-04-13 21:53:48 +01:00
parent 6b4a50ceb5
commit bec7e14aba
7 changed files with 17 additions and 17 deletions
+1 -1
View File
@@ -84,7 +84,7 @@
"rimraf": "3.0.2",
"safe-json-stringify": "1.2.0",
"seq-logging": "1.1.1",
"tachi-common": "0.7.13",
"tachi-common": "0.7.14",
"ts-node": "10.4.0",
"tsconfig-paths": "3.12.0",
"typescript": "4.5.5",
+4 -4
View File
@@ -65,7 +65,7 @@ specifiers:
safe-json-stringify: 1.2.0
seq-logging: 1.1.1
supertest: 6.2.2
tachi-common: 0.7.13
tachi-common: 0.7.14
tap: 15.1.6
ts-node: 10.4.0
tsconfig-paths: 3.12.0
@@ -112,7 +112,7 @@ dependencies:
rimraf: 3.0.2
safe-json-stringify: 1.2.0
seq-logging: 1.1.1
tachi-common: 0.7.13
tachi-common: 0.7.14
ts-node: 10.4.0_2615db9039ce432b4abf2fc39ef336ec
tsconfig-paths: 3.12.0
typescript: 4.5.5
@@ -5363,8 +5363,8 @@ packages:
engines: {node: '>= 0.4'}
dev: true
/tachi-common/0.7.13:
resolution: {integrity: sha512-r0pB7FO6QZ7j16jR0YgMzojbGxo03uS+mDGrD59dpL0tbN2V7fR6vLx+mmWELFBqrDIjcOJu2AOTkz7fPYL3fA==}
/tachi-common/0.7.14:
resolution: {integrity: sha512-RZfmSvCrITGm3jClZZc4JJAJwo6lUU+Wkq2+PAQh7gHdlR5OjVlTNDQr67F3F2KTagz6Sw4y1BDKw78j2aPl8Q==}
dependencies:
'@types/mongodb': 3.6.18
dev: false
+2 -2
View File
@@ -634,7 +634,7 @@ export const DatabaseSchemas: Record<
value: "number",
},
{
mode: p.isIn("abs", "proportion"),
mode: p.isIn("absolute", "proportion"),
countNum: p.isPositive,
key: p.isIn(
"scoreData.percent",
@@ -683,7 +683,7 @@ export const DatabaseSchemas: Record<
type: "all",
},
{
type: p.isIn("abs", "proportion"),
type: p.isIn("absolute", "proportion"),
value: p.isPositive,
}
),
+2 -2
View File
@@ -35,7 +35,7 @@ export async function CreateGoalTitle(
return `${formattedCriteria} any chart in ${datasetName}`;
}
// eslint-disable-next-line no-fallthrough
case "abs":
case "absolute":
switch (charts.type) {
case "any":
return `${formattedCriteria} ${criteria.countNum} charts`;
@@ -178,7 +178,7 @@ export async function ValidateGoalChartsAndCriteria(
);
}
} else if (
criteria.mode === "abs" &&
criteria.mode === "absolute" &&
(criteria.countNum > chartCount ||
!Number.isInteger(criteria.countNum) ||
criteria.countNum < 2)
+2 -2
View File
@@ -148,11 +148,11 @@ export async function EvaluateGoalForUser(
nextBestScore
),
};
} else if (goal.criteria.mode === "abs" || goal.criteria.mode === "proportion") {
} else if (goal.criteria.mode === "absolute" || goal.criteria.mode === "proportion") {
let count;
// abs -> Absolute mode, such as clear 10 charts.
if (goal.criteria.mode === "abs") {
if (goal.criteria.mode === "absolute") {
count = goal.criteria.countNum;
} else {
// proportion -> Proportional mode, the value
@@ -102,7 +102,7 @@ t.test("POST /api/v1/users/:userID/games/:game/:playtype/targets/add-goal", asyn
};
const absModeCriteria = {
mode: "abs",
mode: "absolute",
countNum: 2,
};
@@ -422,7 +422,7 @@ t.test("POST /api/v1/users/:userID/games/:game/:playtype/targets/add-goal", asyn
}),
mkInput("abs without countNum", {
criteria: {
mode: "abs",
mode: "absolute",
},
charts: multiCharts,
}),
@@ -466,7 +466,7 @@ t.test("POST /api/v1/users/:userID/games/:game/:playtype/targets/add-goal", asyn
}),
mkInput("abs with countNum but charts.type == single", {
criteria: {
mode: "abs",
mode: "absolute",
countNum: 1,
},
charts: {
@@ -542,7 +542,7 @@ t.test("POST /api/v1/users/:userID/games/:game/:playtype/targets/add-goal", asyn
}),
mkInput("charts single but criteria not.", {
criteria: {
mode: "abs",
mode: "absolute",
countNum: 2,
},
}),
@@ -53,7 +53,7 @@ type GoalCreationBody = Pick<GoalDocument, "charts" | "criteria">;
*
* @param criteria.key - The key for the goal to be on. This is stuff like scoreData.percent.
* @param criteria.value - The value the key must be greater than for it to count as achieved.
* @param criteria.mode - "single", "abs" or "proportion". If abs or proportion, countNum
* @param criteria.mode - "single", "absolute" or "proportion". If abs or proportion, countNum
* must be supplied.
* @param criteria.countNum - For abs/proportion mode. Atleast N scores must achieve the
* key:value condition.
@@ -79,7 +79,7 @@ router.post(
),
// we do proper validation on this later.
value: p.gte(0),
mode: p.isIn("single", "abs", "proportion"),
mode: p.isIn("single", "absolute", "proportion"),
countNum: (self, parent) => {
if (parent.mode === "single") {
return (