luckytri 1.3.2 → 1.3.3

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.
@@ -406,57 +406,60 @@ export class Works {
406
406
  const terms = interestTerms([words]);
407
407
  // Search the work catalogue, not just the two newest activities. Select
408
408
  // the version that existed at the requested time, including in replays.
409
- return this.db
410
- .prepare(
411
- `SELECT w.*,COALESCE(p.kind,(SELECT kind FROM mind_creations WHERE id=w.legacy_creation)) kind,p.title project_title,p.bible,v.version,v.title,v.created version_created,v.summary,v.sources,v.provenance,length(v.content) characters
409
+ return (
410
+ this.db
411
+ .prepare(
412
+ `SELECT w.*,COALESCE(p.kind,(SELECT kind FROM mind_creations WHERE id=w.legacy_creation)) kind,p.title project_title,p.bible,v.version,v.title,v.created version_created,v.summary,v.sources,v.provenance,length(v.content) characters
412
413
  FROM mind_time_works w LEFT JOIN mind_time_projects p ON p.id=w.project_id
413
414
  JOIN mind_time_versions v ON v.work_id=w.id AND v.version=(SELECT max(h.version) FROM mind_time_versions h WHERE h.work_id=w.id AND h.created<=?)
414
415
  WHERE w.created<=? ORDER BY v.created DESC`,
415
- )
416
- .all(now, now)
417
- .filter(
418
- (w) =>
419
- w.created <= now &&
420
- this.time.visible(
421
- { ...w, sources: parse(w.sources, []) },
422
- session,
423
- now,
424
- ),
425
- )
426
- .map((w) => ({
427
- ...w,
428
- score: [...interestTerms([w.title, w.project_title, w.summary])]
429
- .filter((term) => terms.has(term))
430
- .reduce(
431
- (total, term) => total + (/^[a-z][a-z0-9]{2,}$/.test(term) ? 8 : 1),
432
- 0,
433
- ),
434
- }))
435
- .sort(
436
- (a, b) => b.score - a.score || b.version_created - a.version_created,
437
- )
438
- .filter((w, index, rows) =>
439
- rows[0]?.score >= 2 ? w.score >= 2 : index < 2,
440
- )
441
- .filter((w) => this.materialSupported(w))
442
- .slice(0, 3)
443
- .map((w) => ({
444
- id: w.id,
445
- title: w.title,
446
- state: this.get(w.id, w.version, { before: now }).state,
447
- kind: w.kind,
448
- version: w.version,
449
- ordinal: w.ordinal,
450
- summary: text(w.summary, 180),
451
- fragment: text(this.get(w.id, w.version).content, 300),
452
- ...(w.kind === "game"
453
- ? {
454
- experienceMode: "reference",
455
- provenance: this.get(w.id, w.version).provenance,
456
- }
457
- : {}),
458
- characters: w.characters,
459
- }));
416
+ )
417
+ .all(now, now)
418
+ .filter(
419
+ (w) =>
420
+ w.created <= now &&
421
+ this.time.visible(
422
+ { ...w, sources: parse(w.sources, []) },
423
+ session,
424
+ now,
425
+ ),
426
+ )
427
+ .map((w) => ({
428
+ ...w,
429
+ score: [...interestTerms([w.title, w.project_title, w.summary])]
430
+ .filter((term) => terms.has(term))
431
+ .reduce(
432
+ (total, term) =>
433
+ total + (/^[a-z][a-z0-9]{2,}$/.test(term) ? 8 : 1),
434
+ 0,
435
+ ),
436
+ }))
437
+ .sort(
438
+ (a, b) => b.score - a.score || b.version_created - a.version_created,
439
+ )
440
+ // No topic hit → empty. Do not fall back to "latest two" and pollute
441
+ // ordinary chatter with manuscript fragments.
442
+ .filter((w) => w.score >= 2)
443
+ .filter((w) => this.materialSupported(w))
444
+ .slice(0, 3)
445
+ .map((w) => ({
446
+ id: w.id,
447
+ title: w.title,
448
+ state: this.get(w.id, w.version, { before: now }).state,
449
+ kind: w.kind,
450
+ version: w.version,
451
+ ordinal: w.ordinal,
452
+ summary: text(w.summary, 180),
453
+ fragment: text(this.get(w.id, w.version).content, 300),
454
+ ...(w.kind === "game"
455
+ ? {
456
+ experienceMode: "reference",
457
+ provenance: this.get(w.id, w.version).provenance,
458
+ }
459
+ : {}),
460
+ characters: w.characters,
461
+ }))
462
+ );
460
463
  }
461
464
 
462
465
  activityEvidence({ session, now = this.time.now(), cue = [] } = {}) {