@vue-skuilder/db 0.2.13 → 0.2.15
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/{contentSource-C-0t0y0V.d.ts → contentSource-B1p-vdz7.d.ts} +7 -0
- package/dist/{contentSource-jSkcOt2s.d.cts → contentSource-Brz42x7n.d.cts} +7 -0
- package/dist/core/index.d.cts +3 -3
- package/dist/core/index.d.ts +3 -3
- package/dist/core/index.js +6 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/index.mjs +6 -3
- package/dist/core/index.mjs.map +1 -1
- package/dist/{dataLayerProvider-BB0oi9T0.d.ts → dataLayerProvider-BWayUIoK.d.ts} +1 -1
- package/dist/{dataLayerProvider-BDClIrFC.d.cts → dataLayerProvider-CpwpT1rM.d.cts} +1 -1
- package/dist/impl/couch/index.d.cts +2 -2
- package/dist/impl/couch/index.d.ts +2 -2
- package/dist/impl/couch/index.js +6 -3
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs +6 -3
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.d.cts +2 -2
- package/dist/impl/static/index.d.ts +2 -2
- package/dist/impl/static/index.js +6 -3
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs +6 -3
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.d.cts +47 -5
- package/dist/index.d.ts +47 -5
- package/dist/index.js +50 -30
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +45 -30
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/core/interfaces/userDB.ts +8 -0
- package/src/impl/common/BaseUserDB.ts +2 -2
- package/src/impl/common/userDBHelpers.ts +14 -1
- package/src/index.ts +6 -0
- package/src/study/SessionOverlay.ts +16 -3
- package/src/study/index.ts +4 -0
- package/src/study/services/EloService.ts +20 -8
- package/src/study/services/ResponseProcessor.ts +62 -50
package/dist/index.mjs
CHANGED
|
@@ -221,6 +221,9 @@ var init_dataDirectory = __esm({
|
|
|
221
221
|
|
|
222
222
|
// src/impl/common/userDBHelpers.ts
|
|
223
223
|
import moment from "moment";
|
|
224
|
+
function makeScheduledCardId(reviewTime) {
|
|
225
|
+
return DocTypePrefixes["SCHEDULED_CARD" /* SCHEDULED_CARD */] + moment.utc(reviewTime).format(REVIEW_TIME_FORMAT);
|
|
226
|
+
}
|
|
224
227
|
function hexEncode(str) {
|
|
225
228
|
let hex;
|
|
226
229
|
let returnStr = "";
|
|
@@ -276,7 +279,7 @@ function scheduleCardReviewLocal(userDB, review) {
|
|
|
276
279
|
const now = moment.utc();
|
|
277
280
|
logger.info(`Scheduling for review in: ${review.time.diff(now, "h") / 24} days`);
|
|
278
281
|
void userDB.put({
|
|
279
|
-
_id:
|
|
282
|
+
_id: makeScheduledCardId(review.time),
|
|
280
283
|
cardId: review.card_id,
|
|
281
284
|
reviewTime: review.time.toISOString(),
|
|
282
285
|
courseId: review.course_id,
|
|
@@ -7989,9 +7992,9 @@ Currently logged-in as ${this._username}.`
|
|
|
7989
7992
|
}
|
|
7990
7993
|
}).map((r) => r.doc);
|
|
7991
7994
|
}
|
|
7992
|
-
async getReviewsForcast(daysCount) {
|
|
7995
|
+
async getReviewsForcast(daysCount, course_id) {
|
|
7993
7996
|
const time = moment6.utc().add(daysCount, "days");
|
|
7994
|
-
return this.getReviewstoDate(time);
|
|
7997
|
+
return this.getReviewstoDate(time, course_id);
|
|
7995
7998
|
}
|
|
7996
7999
|
async getPendingReviews(course_id) {
|
|
7997
8000
|
const now = moment6.utc();
|
|
@@ -10996,13 +10999,18 @@ var EloService = class {
|
|
|
10996
10999
|
logger.warn(`k value interpretation not currently implemented`);
|
|
10997
11000
|
}
|
|
10998
11001
|
const courseDB = this.dataLayer.getCourseDB(currentCard.card.course_id);
|
|
10999
|
-
const
|
|
11000
|
-
|
|
11001
|
-
|
|
11002
|
+
const courseReg = userCourseRegDoc.courses.find((c) => c.courseID === course_id);
|
|
11003
|
+
if (!courseReg) {
|
|
11004
|
+
logger.error(
|
|
11005
|
+
`[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?)`
|
|
11006
|
+
);
|
|
11007
|
+
return;
|
|
11008
|
+
}
|
|
11009
|
+
const userElo = toCourseElo7(courseReg.elo);
|
|
11002
11010
|
const cardElo = (await courseDB.getCardEloData([currentCard.card.card_id]))[0];
|
|
11003
11011
|
if (cardElo && userElo) {
|
|
11004
11012
|
const eloUpdate = adjustCourseScores(userElo, cardElo, userScore);
|
|
11005
|
-
|
|
11013
|
+
courseReg.elo = eloUpdate.userElo;
|
|
11006
11014
|
const results = await Promise.allSettled([
|
|
11007
11015
|
this.user.updateUserElo(course_id, eloUpdate.userElo),
|
|
11008
11016
|
courseDB.updateCardElo(card_id, eloUpdate.cardElo)
|
|
@@ -11047,9 +11055,14 @@ var EloService = class {
|
|
|
11047
11055
|
*/
|
|
11048
11056
|
async updateUserAndCardEloPerTag(taggedPerformance, course_id, card_id, userCourseRegDoc, currentCard) {
|
|
11049
11057
|
const courseDB = this.dataLayer.getCourseDB(currentCard.card.course_id);
|
|
11050
|
-
const
|
|
11051
|
-
|
|
11052
|
-
|
|
11058
|
+
const courseReg = userCourseRegDoc.courses.find((c) => c.courseID === course_id);
|
|
11059
|
+
if (!courseReg) {
|
|
11060
|
+
logger.error(
|
|
11061
|
+
`[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?)`
|
|
11062
|
+
);
|
|
11063
|
+
return;
|
|
11064
|
+
}
|
|
11065
|
+
const userElo = toCourseElo7(courseReg.elo);
|
|
11053
11066
|
const [cardEloResults, cardTagsMap] = await Promise.all([
|
|
11054
11067
|
courseDB.getCardEloData([currentCard.card.card_id]),
|
|
11055
11068
|
courseDB.getAppliedTagsBatch([card_id])
|
|
@@ -11065,7 +11078,7 @@ var EloService = class {
|
|
|
11065
11078
|
}
|
|
11066
11079
|
if (cardElo && userElo) {
|
|
11067
11080
|
const eloUpdate = adjustCourseScoresPerTag(userElo, cardElo, enriched);
|
|
11068
|
-
|
|
11081
|
+
courseReg.elo = eloUpdate.userElo;
|
|
11069
11082
|
const results = await Promise.allSettled([
|
|
11070
11083
|
this.user.updateUserElo(course_id, eloUpdate.userElo),
|
|
11071
11084
|
courseDB.updateCardElo(card_id, eloUpdate.cardElo)
|
|
@@ -11112,6 +11125,14 @@ var ResponseProcessor = class {
|
|
|
11112
11125
|
this.srsService = srsService;
|
|
11113
11126
|
this.eloService = eloService;
|
|
11114
11127
|
}
|
|
11128
|
+
/**
|
|
11129
|
+
* ELO updates are fired without awaiting so response handling isn't blocked
|
|
11130
|
+
* on DB writes — but an unhandled rejection silently drops the update.
|
|
11131
|
+
* This produces a catch handler that surfaces the failure in logs.
|
|
11132
|
+
*/
|
|
11133
|
+
logEloFailure(context, cardId) {
|
|
11134
|
+
return (e) => logger.error(`[ResponseProcessor] ELO update failed (${context}) for ${cardId}:`, e);
|
|
11135
|
+
}
|
|
11115
11136
|
/**
|
|
11116
11137
|
* Parses performance data into global score and optional per-tag scores.
|
|
11117
11138
|
*
|
|
@@ -11229,17 +11250,11 @@ var ResponseProcessor = class {
|
|
|
11229
11250
|
cardId,
|
|
11230
11251
|
courseRegistrationDoc,
|
|
11231
11252
|
currentCard
|
|
11232
|
-
);
|
|
11253
|
+
).catch(this.logEloFailure("correct per-tag", cardId));
|
|
11233
11254
|
} else {
|
|
11234
11255
|
const userScore = 0.5 + globalScore / 2;
|
|
11235
11256
|
if (history.records.length === 1) {
|
|
11236
|
-
void this.eloService.updateUserAndCardElo(
|
|
11237
|
-
userScore,
|
|
11238
|
-
courseId,
|
|
11239
|
-
cardId,
|
|
11240
|
-
courseRegistrationDoc,
|
|
11241
|
-
currentCard
|
|
11242
|
-
);
|
|
11257
|
+
void this.eloService.updateUserAndCardElo(userScore, courseId, cardId, courseRegistrationDoc, currentCard).catch(this.logEloFailure("correct", cardId));
|
|
11243
11258
|
} else {
|
|
11244
11259
|
const k = Math.ceil(32 / history.records.length);
|
|
11245
11260
|
void this.eloService.updateUserAndCardElo(
|
|
@@ -11249,7 +11264,7 @@ var ResponseProcessor = class {
|
|
|
11249
11264
|
courseRegistrationDoc,
|
|
11250
11265
|
currentCard,
|
|
11251
11266
|
k
|
|
11252
|
-
);
|
|
11267
|
+
).catch(this.logEloFailure("correct repeat-view", cardId));
|
|
11253
11268
|
}
|
|
11254
11269
|
logger.info(
|
|
11255
11270
|
`[FirstContactElo] correct first-attempt ELO update (score=${userScore.toFixed(3)}) for ${cardId} (historyLen=${history.records.length}, priorAttemps=${cardRecord.priorAttemps})`
|
|
@@ -11290,7 +11305,7 @@ var ResponseProcessor = class {
|
|
|
11290
11305
|
cardId,
|
|
11291
11306
|
courseRegistrationDoc,
|
|
11292
11307
|
currentCard
|
|
11293
|
-
);
|
|
11308
|
+
).catch(this.logEloFailure("incorrect per-tag", cardId));
|
|
11294
11309
|
logger.info(
|
|
11295
11310
|
`[FirstContactElo] incorrect first-attempt per-tag ELO update for ${cardId} (historyLen=${history.records.length}, priorAttemps=${cardRecord.priorAttemps}, tags=${Object.keys(taggedPerformance).length - 1})`
|
|
11296
11311
|
);
|
|
@@ -11302,7 +11317,7 @@ var ResponseProcessor = class {
|
|
|
11302
11317
|
cardId,
|
|
11303
11318
|
courseRegistrationDoc,
|
|
11304
11319
|
currentCard
|
|
11305
|
-
);
|
|
11320
|
+
).catch(this.logEloFailure("incorrect", cardId));
|
|
11306
11321
|
logger.info(
|
|
11307
11322
|
`[FirstContactElo] incorrect first-attempt ELO update (score=0) for ${cardId} (historyLen=${history.records.length}, priorAttemps=${cardRecord.priorAttemps})`
|
|
11308
11323
|
);
|
|
@@ -11323,15 +11338,9 @@ var ResponseProcessor = class {
|
|
|
11323
11338
|
cardId,
|
|
11324
11339
|
courseRegistrationDoc,
|
|
11325
11340
|
currentCard
|
|
11326
|
-
);
|
|
11341
|
+
).catch(this.logEloFailure("dismiss-failed per-tag", cardId));
|
|
11327
11342
|
} else {
|
|
11328
|
-
void this.eloService.updateUserAndCardElo(
|
|
11329
|
-
0,
|
|
11330
|
-
courseId,
|
|
11331
|
-
cardId,
|
|
11332
|
-
courseRegistrationDoc,
|
|
11333
|
-
currentCard
|
|
11334
|
-
);
|
|
11343
|
+
void this.eloService.updateUserAndCardElo(0, courseId, cardId, courseRegistrationDoc, currentCard).catch(this.logEloFailure("dismiss-failed", cardId));
|
|
11335
11344
|
}
|
|
11336
11345
|
logger.info(
|
|
11337
11346
|
`[FirstContactElo] dismiss-failed final ELO penalty for ${cardId} (historyLen=${history.records.length}, sessionViews=${sessionViews})`
|
|
@@ -15154,6 +15163,7 @@ init_TagFilteredContentSource();
|
|
|
15154
15163
|
|
|
15155
15164
|
// src/index.ts
|
|
15156
15165
|
init_factory();
|
|
15166
|
+
init_userDBHelpers();
|
|
15157
15167
|
export {
|
|
15158
15168
|
ContentNavigator,
|
|
15159
15169
|
CouchDBToStaticPacker,
|
|
@@ -15171,6 +15181,7 @@ export {
|
|
|
15171
15181
|
NavigatorRoles,
|
|
15172
15182
|
Navigators,
|
|
15173
15183
|
QuotaRoundRobinMixer,
|
|
15184
|
+
REVIEW_TIME_FORMAT,
|
|
15174
15185
|
SessionController,
|
|
15175
15186
|
StaticToCouchDBMigrator,
|
|
15176
15187
|
TagFilteredContentSource,
|
|
@@ -15191,6 +15202,7 @@ export {
|
|
|
15191
15202
|
docIsDeleted,
|
|
15192
15203
|
endSessionTracking,
|
|
15193
15204
|
ensureAppDataDirectory,
|
|
15205
|
+
getActiveController,
|
|
15194
15206
|
getActivePipeline,
|
|
15195
15207
|
getAppDataDirectory,
|
|
15196
15208
|
getCardHistoryID,
|
|
@@ -15216,6 +15228,7 @@ export {
|
|
|
15216
15228
|
isQuestionTypeRegistered,
|
|
15217
15229
|
isReview,
|
|
15218
15230
|
log,
|
|
15231
|
+
makeScheduledCardId,
|
|
15219
15232
|
mixerDebugAPI,
|
|
15220
15233
|
mountMixerDebugger,
|
|
15221
15234
|
mountPipelineDebugger,
|
|
@@ -15227,6 +15240,7 @@ export {
|
|
|
15227
15240
|
processCustomQuestionsData,
|
|
15228
15241
|
recordCardPresentation,
|
|
15229
15242
|
recordUserOutcome,
|
|
15243
|
+
registerActiveController,
|
|
15230
15244
|
registerBlanksCard,
|
|
15231
15245
|
registerCustomQuestionTypes,
|
|
15232
15246
|
registerDataShape,
|
|
@@ -15241,6 +15255,7 @@ export {
|
|
|
15241
15255
|
sessionDebugAPI,
|
|
15242
15256
|
snapshotQueues,
|
|
15243
15257
|
startSessionTracking,
|
|
15258
|
+
toggleSessionOverlay,
|
|
15244
15259
|
updateLearningState,
|
|
15245
15260
|
updateStrategyWeight,
|
|
15246
15261
|
userDBDebugAPI,
|