refactor admin navigation; update links to ingest pages and improve loading of data in parallel

This commit is contained in:
ImBenji 2026-04-24 00:57:32 +01:00
parent 3c57896aa0
commit 8e654ff467

View file

@ -61,22 +61,31 @@ async function runSignalWorker(archiveDb, intelligenceDb, config) {
try {
const companies = getCompanies.all();
// pick the company with the oldest (or missing) signal
// pick the company with the oldest (or missing) signal that has enough predictions
let target = null;
let oldestTs = null;
const companiesByAge = [];
for (const company of companies) {
const row = getLastSignal.get(company.id);
if (!row) {
// never generated — highest priority
target = company;
break;
companiesByAge.push({ company, ts: row ? row.generated_at : null });
}
if (oldestTs === null || row.generated_at < oldestTs) {
oldestTs = row.generated_at;
target = company;
// null ts (never generated) first, then oldest
companiesByAge.sort((a, b) => {
if (a.ts === null && b.ts === null) return 0;
if (a.ts === null) return -1;
if (b.ts === null) return 1;
return a.ts < b.ts ? -1 : 1;
});
let predictions = null;
for (const entry of companiesByAge) {
const preds = getPredictions.all(entry.company.id);
if (preds.length >= 3) {
target = entry.company;
predictions = preds;
break;
}
}
@ -85,14 +94,6 @@ async function runSignalWorker(archiveDb, intelligenceDb, config) {
continue;
}
const predictions = getPredictions.all(target.id);
if (predictions.length < 3) {
await sleep(loopDelay);
continue;
}
const facts = getFacts.all(target.id);
const relationships = getRelationships.all(target.id);