@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.d.cts
CHANGED
|
@@ -19,7 +19,16 @@ import moment from 'moment';
|
|
|
19
19
|
declare class EloService {
|
|
20
20
|
private dataLayer;
|
|
21
21
|
private user;
|
|
22
|
+
/** Per course ID: its compiled `CourseConfig.qaUsernamePattern`, or null. */
|
|
23
|
+
private qaPatterns;
|
|
22
24
|
constructor(dataLayer: DataLayerProvider, user: UserDBInterface);
|
|
25
|
+
/**
|
|
26
|
+
* Whether the current user is one of the course's QA accounts
|
|
27
|
+
* (`CourseConfig.qaUsernamePattern`), whose responses must not move card
|
|
28
|
+
* ELO. The pattern is read once per course. If the config is unreadable or
|
|
29
|
+
* the pattern doesn't compile, nobody is a QA account.
|
|
30
|
+
*/
|
|
31
|
+
private isQaUser;
|
|
23
32
|
/**
|
|
24
33
|
* Updates both user and card ELO ratings based on user performance.
|
|
25
34
|
* @param userScore Score between 0-1 representing user performance
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,16 @@ import moment from 'moment';
|
|
|
19
19
|
declare class EloService {
|
|
20
20
|
private dataLayer;
|
|
21
21
|
private user;
|
|
22
|
+
/** Per course ID: its compiled `CourseConfig.qaUsernamePattern`, or null. */
|
|
23
|
+
private qaPatterns;
|
|
22
24
|
constructor(dataLayer: DataLayerProvider, user: UserDBInterface);
|
|
25
|
+
/**
|
|
26
|
+
* Whether the current user is one of the course's QA accounts
|
|
27
|
+
* (`CourseConfig.qaUsernamePattern`), whose responses must not move card
|
|
28
|
+
* ELO. The pattern is read once per course. If the config is unreadable or
|
|
29
|
+
* the pattern doesn't compile, nobody is a QA account.
|
|
30
|
+
*/
|
|
31
|
+
private isQaUser;
|
|
23
32
|
/**
|
|
24
33
|
* Updates both user and card ELO ratings based on user performance.
|
|
25
34
|
* @param userScore Score between 0-1 representing user performance
|
package/dist/index.js
CHANGED
|
@@ -5539,7 +5539,7 @@ var FRAMEWORK_VERSION, hostAppVersion, DEFAULT_STRATEGY_HASH;
|
|
|
5539
5539
|
var init_versionStamps = __esm({
|
|
5540
5540
|
"src/core/versionStamps.ts"() {
|
|
5541
5541
|
"use strict";
|
|
5542
|
-
FRAMEWORK_VERSION = true ? "0.2.
|
|
5542
|
+
FRAMEWORK_VERSION = true ? "0.2.33" : "dev";
|
|
5543
5543
|
DEFAULT_STRATEGY_HASH = "default";
|
|
5544
5544
|
}
|
|
5545
5545
|
});
|
|
@@ -8286,10 +8286,30 @@ var init_EloService = __esm({
|
|
|
8286
8286
|
EloService = class {
|
|
8287
8287
|
dataLayer;
|
|
8288
8288
|
user;
|
|
8289
|
+
/** Per course ID: its compiled `CourseConfig.qaUsernamePattern`, or null. */
|
|
8290
|
+
qaPatterns = /* @__PURE__ */ new Map();
|
|
8289
8291
|
constructor(dataLayer, user) {
|
|
8290
8292
|
this.dataLayer = dataLayer;
|
|
8291
8293
|
this.user = user;
|
|
8292
8294
|
}
|
|
8295
|
+
/**
|
|
8296
|
+
* Whether the current user is one of the course's QA accounts
|
|
8297
|
+
* (`CourseConfig.qaUsernamePattern`), whose responses must not move card
|
|
8298
|
+
* ELO. The pattern is read once per course. If the config is unreadable or
|
|
8299
|
+
* the pattern doesn't compile, nobody is a QA account.
|
|
8300
|
+
*/
|
|
8301
|
+
async isQaUser(courseDB) {
|
|
8302
|
+
const courseId = courseDB.getCourseID();
|
|
8303
|
+
let pattern = this.qaPatterns.get(courseId);
|
|
8304
|
+
if (!pattern) {
|
|
8305
|
+
pattern = courseDB.getCourseConfig().then((cfg) => cfg.qaUsernamePattern ? new RegExp(cfg.qaUsernamePattern, "i") : null).catch((e) => {
|
|
8306
|
+
logger.warn(`[EloService] No QA username pattern for ${courseId}: ${e}`);
|
|
8307
|
+
return null;
|
|
8308
|
+
});
|
|
8309
|
+
this.qaPatterns.set(courseId, pattern);
|
|
8310
|
+
}
|
|
8311
|
+
return (await pattern)?.test(this.user.getUsername()) ?? false;
|
|
8312
|
+
}
|
|
8293
8313
|
/**
|
|
8294
8314
|
* Updates both user and card ELO ratings based on user performance.
|
|
8295
8315
|
* @param userScore Score between 0-1 representing user performance
|
|
@@ -8316,6 +8336,7 @@ var init_EloService = __esm({
|
|
|
8316
8336
|
const userElo = (0, import_common16.toCourseElo)(courseReg.elo);
|
|
8317
8337
|
const cardElo = (await courseDB.getCardEloData([currentCard.card.card_id]))[0];
|
|
8318
8338
|
if (cardElo && userElo) {
|
|
8339
|
+
const writeCard = !await this.isQaUser(courseDB);
|
|
8319
8340
|
const beforeUserGlobal = userElo.global.score;
|
|
8320
8341
|
const beforeCardGlobal = cardElo.global.score;
|
|
8321
8342
|
const cardTagKeys = Object.keys(cardElo.tags);
|
|
@@ -8339,12 +8360,18 @@ var init_EloService = __esm({
|
|
|
8339
8360
|
at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8340
8361
|
userScore,
|
|
8341
8362
|
global: { before: beforeUserGlobal, after: eloUpdate.userElo.global.score },
|
|
8342
|
-
card: {
|
|
8363
|
+
card: {
|
|
8364
|
+
before: beforeCardGlobal,
|
|
8365
|
+
after: writeCard ? eloUpdate.cardElo.global.score : beforeCardGlobal
|
|
8366
|
+
},
|
|
8343
8367
|
...cardTagKeys.length ? { tags } : {}
|
|
8344
8368
|
};
|
|
8369
|
+
if (!writeCard) {
|
|
8370
|
+
logger.info(`[EloService] QA account: card ELO for ${card_id} not written`);
|
|
8371
|
+
}
|
|
8345
8372
|
const results = await Promise.allSettled([
|
|
8346
8373
|
this.user.updateUserElo(course_id, eloUpdate.userElo),
|
|
8347
|
-
courseDB.updateCardElo(card_id, eloUpdate.cardElo)
|
|
8374
|
+
writeCard ? courseDB.updateCardElo(card_id, eloUpdate.cardElo) : Promise.resolve(null)
|
|
8348
8375
|
]);
|
|
8349
8376
|
const userEloStatus = results[0].status === "fulfilled";
|
|
8350
8377
|
const cardEloStatus = results[1].status === "fulfilled";
|
|
@@ -8411,6 +8438,7 @@ var init_EloService = __esm({
|
|
|
8411
8438
|
}
|
|
8412
8439
|
}
|
|
8413
8440
|
if (cardElo && userElo) {
|
|
8441
|
+
const writeCard = !await this.isQaUser(courseDB);
|
|
8414
8442
|
const beforeUserGlobal = userElo.global.score;
|
|
8415
8443
|
const beforeCardGlobal = cardElo.global.score;
|
|
8416
8444
|
const touchedTags = Object.keys(enriched).filter((key) => key !== "_global");
|
|
@@ -8442,12 +8470,18 @@ var init_EloService = __esm({
|
|
|
8442
8470
|
at,
|
|
8443
8471
|
userScore: globalScore,
|
|
8444
8472
|
global: { before: beforeUserGlobal, after: eloUpdate.userElo.global.score },
|
|
8445
|
-
card: {
|
|
8473
|
+
card: {
|
|
8474
|
+
before: beforeCardGlobal,
|
|
8475
|
+
after: writeCard ? eloUpdate.cardElo.global.score : beforeCardGlobal
|
|
8476
|
+
},
|
|
8446
8477
|
...touchedTags.length ? { tags } : {}
|
|
8447
8478
|
};
|
|
8479
|
+
if (!writeCard) {
|
|
8480
|
+
logger.info(`[EloService] QA account: card ELO for ${card_id} not written`);
|
|
8481
|
+
}
|
|
8448
8482
|
const results = await Promise.allSettled([
|
|
8449
8483
|
this.user.updateUserElo(course_id, eloUpdate.userElo),
|
|
8450
|
-
courseDB.updateCardElo(card_id, eloUpdate.cardElo)
|
|
8484
|
+
writeCard ? courseDB.updateCardElo(card_id, eloUpdate.cardElo) : Promise.resolve(null)
|
|
8451
8485
|
]);
|
|
8452
8486
|
const userEloStatus = results[0].status === "fulfilled";
|
|
8453
8487
|
const cardEloStatus = results[1].status === "fulfilled";
|