renewProfiles
uses tcmts.registry.people, which uses tcmts.server.table, which uses tcmts.server.Table, which uses #tcm/host (database)
Read again the profiles of people the registry knows whose profile it read a day ago or more, or never: most at a
time. One whose repository doesn't answer keeps what it had, until the next day. How many it read.
import { people, profileOf } from "#codebase/tcmts/registry"; import type { Someone } from "#codebase/tcmts/registry"; export async function renewProfiles(most = 20): Promise<number> { const day = 24 * 60 * 60 * 1000; const due = (await people.find()) .filter((p) => !p.value.profileAt || Date.now() - p.value.profileAt.getTime() > day) .slice(0, most); for (const p of due) { let got: Omit<Someone, "did"> | undefined; try { got = await profileOf(p.value.did); } catch {} await people.update(p.id, (v) => { if (!got) return { ...v, profileAt: new Date() }; const { name: _, bio: __, avatar: ___, ...rest } = v; return { ...rest, ...got, profileAt: new Date() }; }); } return due.length; }