Fill the hierarchy's place words from other records with the same code
When a book's own Library of Congress record has no subject heading, the place or topic words now come from a verified record of the same work with the same class key, and failing that from the part that the similar-search records with that key agree on. Books that previously found nothing are re-checked once at startup. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
1 parent
60fa4ef6f7
commit
c1996d2b47
6 files changed
+279
-25
No files matched your search
+33
-3
@@ -304,7 +304,7 @@ test('tail backfill changes only the tail, emits the update, and never touches s
|
||||
assert.equal(calls.length, 1);
|
||||
});
|
||||
|
||||
test('tail backfill: no identifiers, hand entries and similar numbers get [] without asking', async () => {
|
||||
test('tail backfill: hand entries get [] without asking; every other book is asked, whatever its source', async () => {
|
||||
const { db } = setup(async () => found);
|
||||
const asked: unknown[] = [];
|
||||
const resolver: ResolverLike = { resolve: async () => found, search: async () => [], tail: async (i) => { asked.push(i); return ['X']; } };
|
||||
@@ -316,9 +316,39 @@ test('tail backfill: no identifiers, hand entries and similar numbers get [] wit
|
||||
const pending = db.insertPending({ isbn13: '9780000000026', title: 'p' }).book; // status pending: the lookup's job
|
||||
jobs.resumeTails();
|
||||
await jobs.idle();
|
||||
for (const b of [none, manual, similar, byHand]) assert.deepEqual(db.getBook(b.id)!.hierarchyTail, [], b.title);
|
||||
for (const b of [manual, byHand]) assert.deepEqual(db.getBook(b.id)!.hierarchyTail, [], b.title);
|
||||
for (const b of [none, similar]) assert.deepEqual(db.getBook(b.id)!.hierarchyTail, ['X'], b.title);
|
||||
assert.equal(db.getBook(pending.id)!.hierarchyTail, null);
|
||||
assert.equal(asked.length, 0);
|
||||
assert.equal(asked.length, 2);
|
||||
});
|
||||
|
||||
test('tail rules version: books with [] are checked again once, hand entries and non-empty tails are left alone', async () => {
|
||||
const { db } = setup(async () => found);
|
||||
const asked: string[] = [];
|
||||
const resolver: ResolverLike = {
|
||||
resolve: async () => found, search: async () => [],
|
||||
tail: async (i) => { asked.push(i.isbn13 ?? ''); return ['Utah']; },
|
||||
};
|
||||
const mk = () => createJobs({ db, resolver, onChange: () => {}, retryDelaysMs: [0], log: () => {} });
|
||||
const empty = tailBook(db, { isbn13: '9780000000002', hierarchyTail: [] });
|
||||
const has = tailBook(db, { isbn13: '9780000000019', hierarchyTail: ['Nevada'] });
|
||||
const hand = tailBook(db, { isbn13: '9780000000026', hierarchyTail: [], manualOverride: true, source: 'manual' });
|
||||
const before = db.getBook(empty.id)!;
|
||||
const first = mk();
|
||||
first.resumeTails();
|
||||
await first.idle();
|
||||
assert.deepEqual(asked, ['9780000000002']);
|
||||
assert.deepEqual(db.getBook(empty.id)!.hierarchyTail, ['Utah']);
|
||||
assert.deepEqual(db.getBook(has.id)!.hierarchyTail, ['Nevada']);
|
||||
assert.deepEqual(db.getBook(hand.id)!.hierarchyTail, []);
|
||||
for (const k of ['callNumber', 'sortKey', 'confidence', 'source', 'status', 'inQueue', 'printedAt'] as const) assert.deepEqual(db.getBook(empty.id)![k], before[k], k);
|
||||
// A later start does not ask again, even for a book that is [] again.
|
||||
db.updateBook(empty.id, { hierarchyTail: [] });
|
||||
const second = mk();
|
||||
second.resumeTails();
|
||||
await second.idle();
|
||||
assert.equal(asked.length, 1);
|
||||
assert.deepEqual(db.getBook(empty.id)!.hierarchyTail, []);
|
||||
});
|
||||
|
||||
test('tail backfill: a temporary failure is retried, then left NULL for the next start; a missing record stores []', async () => {
|
||||
|
||||
Reference in new issue
Block a user