refactor admin navigation; update links to ingest pages and improve loading of data in parallel
This commit is contained in:
parent
3c57896aa0
commit
8e654ff467
1 changed files with 18 additions and 17 deletions
|
|
@ -61,23 +61,32 @@ 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);
|
||||
companiesByAge.push({ company, ts: row ? row.generated_at : null });
|
||||
}
|
||||
|
||||
if (!row) {
|
||||
// never generated — highest priority
|
||||
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;
|
||||
}
|
||||
|
||||
if (oldestTs === null || row.generated_at < oldestTs) {
|
||||
oldestTs = row.generated_at;
|
||||
target = company;
|
||||
}
|
||||
}
|
||||
|
||||
if (!target) {
|
||||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue