@vue-skuilder/db 0.1.33 → 0.1.34

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.
@@ -2311,7 +2311,26 @@ var init_srs = __esm({
2311
2311
  const courseId = this.course.getCourseID();
2312
2312
  const reviews = await this.user.getPendingReviews(courseId);
2313
2313
  const now = moment.utc();
2314
- const dueReviews = reviews.filter((r) => now.isAfter(moment.utc(r.reviewTime)));
2314
+ let dueReviews = reviews.filter((r) => now.isAfter(moment.utc(r.reviewTime)));
2315
+ if (dueReviews.length > 0) {
2316
+ const dueCardIds = [...new Set(dueReviews.map((r) => r.cardId))];
2317
+ const tagsByCard = await this.course.getAppliedTagsBatch(dueCardIds);
2318
+ const skippedReviewIds = [];
2319
+ dueReviews = dueReviews.filter((r) => {
2320
+ const tags = tagsByCard.get(r.cardId) ?? [];
2321
+ if (tags.includes("srs:skip")) {
2322
+ skippedReviewIds.push(r._id);
2323
+ return false;
2324
+ }
2325
+ return true;
2326
+ });
2327
+ if (skippedReviewIds.length > 0) {
2328
+ logger.info(`[SRS] Removing ${skippedReviewIds.length} scheduled reviews for srs:skip cards`);
2329
+ for (const id of skippedReviewIds) {
2330
+ void this.user.removeScheduledCardReview(id);
2331
+ }
2332
+ }
2333
+ }
2315
2334
  const backlogPressure = this.computeBacklogPressure(dueReviews.length);
2316
2335
  if (dueReviews.length > 0) {
2317
2336
  const pressureNote = backlogPressure > 0 ? ` [backlog pressure: +${backlogPressure.toFixed(2)}]` : ` [healthy backlog]`;
@@ -7460,17 +7479,18 @@ Currently logged-in as ${this._username}.`
7460
7479
  * @param course_id optional specification of individual course
7461
7480
  */
7462
7481
  async getSeenCards(course_id) {
7463
- let prefix = DocTypePrefixes["CARDRECORD" /* CARDRECORD */];
7482
+ const basePrefix = DocTypePrefixes["CARDRECORD" /* CARDRECORD */];
7483
+ let filterPrefix = basePrefix;
7464
7484
  if (course_id) {
7465
- prefix += course_id;
7485
+ filterPrefix += `-${course_id}-`;
7466
7486
  }
7467
- const docs = await filterAllDocsByPrefix2(this.localDB, prefix, {
7487
+ const docs = await filterAllDocsByPrefix2(this.localDB, filterPrefix, {
7468
7488
  include_docs: false
7469
7489
  });
7470
7490
  const ret = [];
7471
7491
  docs.rows.forEach((row) => {
7472
- if (row.id.startsWith(DocTypePrefixes["CARDRECORD" /* CARDRECORD */])) {
7473
- ret.push(row.id.substr(DocTypePrefixes["CARDRECORD" /* CARDRECORD */].length));
7492
+ if (row.id.startsWith(filterPrefix)) {
7493
+ ret.push(row.id.substr(filterPrefix.length));
7474
7494
  }
7475
7495
  });
7476
7496
  return ret;