@vue-skuilder/db 0.2.32 → 0.2.33
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/core/index.js.map +1 -1
- package/dist/core/index.mjs.map +1 -1
- package/dist/impl/couch/index.d.cts +9 -0
- package/dist/impl/couch/index.d.ts +9 -0
- package/dist/impl/couch/index.js.map +1 -1
- package/dist/impl/couch/index.mjs.map +1 -1
- package/dist/impl/static/index.js.map +1 -1
- package/dist/impl/static/index.mjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +39 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +39 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/src/study/services/EloService.ts +49 -4
package/dist/index.mjs
CHANGED
|
@@ -5517,7 +5517,7 @@ var FRAMEWORK_VERSION, hostAppVersion, DEFAULT_STRATEGY_HASH;
|
|
|
5517
5517
|
var init_versionStamps = __esm({
|
|
5518
5518
|
"src/core/versionStamps.ts"() {
|
|
5519
5519
|
"use strict";
|
|
5520
|
-
FRAMEWORK_VERSION = true ? "0.2.
|
|
5520
|
+
FRAMEWORK_VERSION = true ? "0.2.33" : "dev";
|
|
5521
5521
|
DEFAULT_STRATEGY_HASH = "default";
|
|
5522
5522
|
}
|
|
5523
5523
|
});
|
|
@@ -8274,10 +8274,30 @@ var init_EloService = __esm({
|
|
|
8274
8274
|
EloService = class {
|
|
8275
8275
|
dataLayer;
|
|
8276
8276
|
user;
|
|
8277
|
+
/** Per course ID: its compiled `CourseConfig.qaUsernamePattern`, or null. */
|
|
8278
|
+
qaPatterns = /* @__PURE__ */ new Map();
|
|
8277
8279
|
constructor(dataLayer, user) {
|
|
8278
8280
|
this.dataLayer = dataLayer;
|
|
8279
8281
|
this.user = user;
|
|
8280
8282
|
}
|
|
8283
|
+
/**
|
|
8284
|
+
* Whether the current user is one of the course's QA accounts
|
|
8285
|
+
* (`CourseConfig.qaUsernamePattern`), whose responses must not move card
|
|
8286
|
+
* ELO. The pattern is read once per course. If the config is unreadable or
|
|
8287
|
+
* the pattern doesn't compile, nobody is a QA account.
|
|
8288
|
+
*/
|
|
8289
|
+
async isQaUser(courseDB) {
|
|
8290
|
+
const courseId = courseDB.getCourseID();
|
|
8291
|
+
let pattern = this.qaPatterns.get(courseId);
|
|
8292
|
+
if (!pattern) {
|
|
8293
|
+
pattern = courseDB.getCourseConfig().then((cfg) => cfg.qaUsernamePattern ? new RegExp(cfg.qaUsernamePattern, "i") : null).catch((e) => {
|
|
8294
|
+
logger.warn(`[EloService] No QA username pattern for ${courseId}: ${e}`);
|
|
8295
|
+
return null;
|
|
8296
|
+
});
|
|
8297
|
+
this.qaPatterns.set(courseId, pattern);
|
|
8298
|
+
}
|
|
8299
|
+
return (await pattern)?.test(this.user.getUsername()) ?? false;
|
|
8300
|
+
}
|
|
8281
8301
|
/**
|
|
8282
8302
|
* Updates both user and card ELO ratings based on user performance.
|
|
8283
8303
|
* @param userScore Score between 0-1 representing user performance
|
|
@@ -8304,6 +8324,7 @@ var init_EloService = __esm({
|
|
|
8304
8324
|
const userElo = toCourseElo7(courseReg.elo);
|
|
8305
8325
|
const cardElo = (await courseDB.getCardEloData([currentCard.card.card_id]))[0];
|
|
8306
8326
|
if (cardElo && userElo) {
|
|
8327
|
+
const writeCard = !await this.isQaUser(courseDB);
|
|
8307
8328
|
const beforeUserGlobal = userElo.global.score;
|
|
8308
8329
|
const beforeCardGlobal = cardElo.global.score;
|
|
8309
8330
|
const cardTagKeys = Object.keys(cardElo.tags);
|
|
@@ -8327,12 +8348,18 @@ var init_EloService = __esm({
|
|
|
8327
8348
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8328
8349
|
userScore,
|
|
8329
8350
|
global: { before: beforeUserGlobal, after: eloUpdate.userElo.global.score },
|
|
8330
|
-
card: {
|
|
8351
|
+
card: {
|
|
8352
|
+
before: beforeCardGlobal,
|
|
8353
|
+
after: writeCard ? eloUpdate.cardElo.global.score : beforeCardGlobal
|
|
8354
|
+
},
|
|
8331
8355
|
...cardTagKeys.length ? { tags } : {}
|
|
8332
8356
|
};
|
|
8357
|
+
if (!writeCard) {
|
|
8358
|
+
logger.info(`[EloService] QA account: card ELO for ${card_id} not written`);
|
|
8359
|
+
}
|
|
8333
8360
|
const results = await Promise.allSettled([
|
|
8334
8361
|
this.user.updateUserElo(course_id, eloUpdate.userElo),
|
|
8335
|
-
courseDB.updateCardElo(card_id, eloUpdate.cardElo)
|
|
8362
|
+
writeCard ? courseDB.updateCardElo(card_id, eloUpdate.cardElo) : Promise.resolve(null)
|
|
8336
8363
|
]);
|
|
8337
8364
|
const userEloStatus = results[0].status === "fulfilled";
|
|
8338
8365
|
const cardEloStatus = results[1].status === "fulfilled";
|
|
@@ -8399,6 +8426,7 @@ var init_EloService = __esm({
|
|
|
8399
8426
|
}
|
|
8400
8427
|
}
|
|
8401
8428
|
if (cardElo && userElo) {
|
|
8429
|
+
const writeCard = !await this.isQaUser(courseDB);
|
|
8402
8430
|
const beforeUserGlobal = userElo.global.score;
|
|
8403
8431
|
const beforeCardGlobal = cardElo.global.score;
|
|
8404
8432
|
const touchedTags = Object.keys(enriched).filter((key) => key !== "_global");
|
|
@@ -8430,12 +8458,18 @@ var init_EloService = __esm({
|
|
|
8430
8458
|
at,
|
|
8431
8459
|
userScore: globalScore,
|
|
8432
8460
|
global: { before: beforeUserGlobal, after: eloUpdate.userElo.global.score },
|
|
8433
|
-
card: {
|
|
8461
|
+
card: {
|
|
8462
|
+
before: beforeCardGlobal,
|
|
8463
|
+
after: writeCard ? eloUpdate.cardElo.global.score : beforeCardGlobal
|
|
8464
|
+
},
|
|
8434
8465
|
...touchedTags.length ? { tags } : {}
|
|
8435
8466
|
};
|
|
8467
|
+
if (!writeCard) {
|
|
8468
|
+
logger.info(`[EloService] QA account: card ELO for ${card_id} not written`);
|
|
8469
|
+
}
|
|
8436
8470
|
const results = await Promise.allSettled([
|
|
8437
8471
|
this.user.updateUserElo(course_id, eloUpdate.userElo),
|
|
8438
|
-
courseDB.updateCardElo(card_id, eloUpdate.cardElo)
|
|
8472
|
+
writeCard ? courseDB.updateCardElo(card_id, eloUpdate.cardElo) : Promise.resolve(null)
|
|
8439
8473
|
]);
|
|
8440
8474
|
const userEloStatus = results[0].status === "fulfilled";
|
|
8441
8475
|
const cardEloStatus = results[1].status === "fulfilled";
|