@vue-skuilder/db 0.2.13 → 0.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.cts +6 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +33 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +33 -27
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/study/services/EloService.ts +20 -8
- package/src/study/services/ResponseProcessor.ts +62 -50
package/dist/index.mjs
CHANGED
|
@@ -10996,13 +10996,18 @@ var EloService = class {
|
|
|
10996
10996
|
logger.warn(`k value interpretation not currently implemented`);
|
|
10997
10997
|
}
|
|
10998
10998
|
const courseDB = this.dataLayer.getCourseDB(currentCard.card.course_id);
|
|
10999
|
-
const
|
|
11000
|
-
|
|
11001
|
-
|
|
10999
|
+
const courseReg = userCourseRegDoc.courses.find((c) => c.courseID === course_id);
|
|
11000
|
+
if (!courseReg) {
|
|
11001
|
+
logger.error(
|
|
11002
|
+
`[EloService] No registration for course ${course_id} on user's registration doc \u2014 skipping ELO update for card ${card_id}. (Is the user registered for this course?)`
|
|
11003
|
+
);
|
|
11004
|
+
return;
|
|
11005
|
+
}
|
|
11006
|
+
const userElo = toCourseElo7(courseReg.elo);
|
|
11002
11007
|
const cardElo = (await courseDB.getCardEloData([currentCard.card.card_id]))[0];
|
|
11003
11008
|
if (cardElo && userElo) {
|
|
11004
11009
|
const eloUpdate = adjustCourseScores(userElo, cardElo, userScore);
|
|
11005
|
-
|
|
11010
|
+
courseReg.elo = eloUpdate.userElo;
|
|
11006
11011
|
const results = await Promise.allSettled([
|
|
11007
11012
|
this.user.updateUserElo(course_id, eloUpdate.userElo),
|
|
11008
11013
|
courseDB.updateCardElo(card_id, eloUpdate.cardElo)
|
|
@@ -11047,9 +11052,14 @@ var EloService = class {
|
|
|
11047
11052
|
*/
|
|
11048
11053
|
async updateUserAndCardEloPerTag(taggedPerformance, course_id, card_id, userCourseRegDoc, currentCard) {
|
|
11049
11054
|
const courseDB = this.dataLayer.getCourseDB(currentCard.card.course_id);
|
|
11050
|
-
const
|
|
11051
|
-
|
|
11052
|
-
|
|
11055
|
+
const courseReg = userCourseRegDoc.courses.find((c) => c.courseID === course_id);
|
|
11056
|
+
if (!courseReg) {
|
|
11057
|
+
logger.error(
|
|
11058
|
+
`[EloService] No registration for course ${course_id} on user's registration doc \u2014 skipping per-tag ELO update for card ${card_id}. (Is the user registered for this course?)`
|
|
11059
|
+
);
|
|
11060
|
+
return;
|
|
11061
|
+
}
|
|
11062
|
+
const userElo = toCourseElo7(courseReg.elo);
|
|
11053
11063
|
const [cardEloResults, cardTagsMap] = await Promise.all([
|
|
11054
11064
|
courseDB.getCardEloData([currentCard.card.card_id]),
|
|
11055
11065
|
courseDB.getAppliedTagsBatch([card_id])
|
|
@@ -11065,7 +11075,7 @@ var EloService = class {
|
|
|
11065
11075
|
}
|
|
11066
11076
|
if (cardElo && userElo) {
|
|
11067
11077
|
const eloUpdate = adjustCourseScoresPerTag(userElo, cardElo, enriched);
|
|
11068
|
-
|
|
11078
|
+
courseReg.elo = eloUpdate.userElo;
|
|
11069
11079
|
const results = await Promise.allSettled([
|
|
11070
11080
|
this.user.updateUserElo(course_id, eloUpdate.userElo),
|
|
11071
11081
|
courseDB.updateCardElo(card_id, eloUpdate.cardElo)
|
|
@@ -11112,6 +11122,14 @@ var ResponseProcessor = class {
|
|
|
11112
11122
|
this.srsService = srsService;
|
|
11113
11123
|
this.eloService = eloService;
|
|
11114
11124
|
}
|
|
11125
|
+
/**
|
|
11126
|
+
* ELO updates are fired without awaiting so response handling isn't blocked
|
|
11127
|
+
* on DB writes — but an unhandled rejection silently drops the update.
|
|
11128
|
+
* This produces a catch handler that surfaces the failure in logs.
|
|
11129
|
+
*/
|
|
11130
|
+
logEloFailure(context, cardId) {
|
|
11131
|
+
return (e) => logger.error(`[ResponseProcessor] ELO update failed (${context}) for ${cardId}:`, e);
|
|
11132
|
+
}
|
|
11115
11133
|
/**
|
|
11116
11134
|
* Parses performance data into global score and optional per-tag scores.
|
|
11117
11135
|
*
|
|
@@ -11229,17 +11247,11 @@ var ResponseProcessor = class {
|
|
|
11229
11247
|
cardId,
|
|
11230
11248
|
courseRegistrationDoc,
|
|
11231
11249
|
currentCard
|
|
11232
|
-
);
|
|
11250
|
+
).catch(this.logEloFailure("correct per-tag", cardId));
|
|
11233
11251
|
} else {
|
|
11234
11252
|
const userScore = 0.5 + globalScore / 2;
|
|
11235
11253
|
if (history.records.length === 1) {
|
|
11236
|
-
void this.eloService.updateUserAndCardElo(
|
|
11237
|
-
userScore,
|
|
11238
|
-
courseId,
|
|
11239
|
-
cardId,
|
|
11240
|
-
courseRegistrationDoc,
|
|
11241
|
-
currentCard
|
|
11242
|
-
);
|
|
11254
|
+
void this.eloService.updateUserAndCardElo(userScore, courseId, cardId, courseRegistrationDoc, currentCard).catch(this.logEloFailure("correct", cardId));
|
|
11243
11255
|
} else {
|
|
11244
11256
|
const k = Math.ceil(32 / history.records.length);
|
|
11245
11257
|
void this.eloService.updateUserAndCardElo(
|
|
@@ -11249,7 +11261,7 @@ var ResponseProcessor = class {
|
|
|
11249
11261
|
courseRegistrationDoc,
|
|
11250
11262
|
currentCard,
|
|
11251
11263
|
k
|
|
11252
|
-
);
|
|
11264
|
+
).catch(this.logEloFailure("correct repeat-view", cardId));
|
|
11253
11265
|
}
|
|
11254
11266
|
logger.info(
|
|
11255
11267
|
`[FirstContactElo] correct first-attempt ELO update (score=${userScore.toFixed(3)}) for ${cardId} (historyLen=${history.records.length}, priorAttemps=${cardRecord.priorAttemps})`
|
|
@@ -11290,7 +11302,7 @@ var ResponseProcessor = class {
|
|
|
11290
11302
|
cardId,
|
|
11291
11303
|
courseRegistrationDoc,
|
|
11292
11304
|
currentCard
|
|
11293
|
-
);
|
|
11305
|
+
).catch(this.logEloFailure("incorrect per-tag", cardId));
|
|
11294
11306
|
logger.info(
|
|
11295
11307
|
`[FirstContactElo] incorrect first-attempt per-tag ELO update for ${cardId} (historyLen=${history.records.length}, priorAttemps=${cardRecord.priorAttemps}, tags=${Object.keys(taggedPerformance).length - 1})`
|
|
11296
11308
|
);
|
|
@@ -11302,7 +11314,7 @@ var ResponseProcessor = class {
|
|
|
11302
11314
|
cardId,
|
|
11303
11315
|
courseRegistrationDoc,
|
|
11304
11316
|
currentCard
|
|
11305
|
-
);
|
|
11317
|
+
).catch(this.logEloFailure("incorrect", cardId));
|
|
11306
11318
|
logger.info(
|
|
11307
11319
|
`[FirstContactElo] incorrect first-attempt ELO update (score=0) for ${cardId} (historyLen=${history.records.length}, priorAttemps=${cardRecord.priorAttemps})`
|
|
11308
11320
|
);
|
|
@@ -11323,15 +11335,9 @@ var ResponseProcessor = class {
|
|
|
11323
11335
|
cardId,
|
|
11324
11336
|
courseRegistrationDoc,
|
|
11325
11337
|
currentCard
|
|
11326
|
-
);
|
|
11338
|
+
).catch(this.logEloFailure("dismiss-failed per-tag", cardId));
|
|
11327
11339
|
} else {
|
|
11328
|
-
void this.eloService.updateUserAndCardElo(
|
|
11329
|
-
0,
|
|
11330
|
-
courseId,
|
|
11331
|
-
cardId,
|
|
11332
|
-
courseRegistrationDoc,
|
|
11333
|
-
currentCard
|
|
11334
|
-
);
|
|
11340
|
+
void this.eloService.updateUserAndCardElo(0, courseId, cardId, courseRegistrationDoc, currentCard).catch(this.logEloFailure("dismiss-failed", cardId));
|
|
11335
11341
|
}
|
|
11336
11342
|
logger.info(
|
|
11337
11343
|
`[FirstContactElo] dismiss-failed final ELO penalty for ${cardId} (historyLen=${history.records.length}, sessionViews=${sessionViews})`
|