[profile] #290 generic rel=me (links table) - random order (useful when multiple workers)

This commit is contained in:
Andrea Vos 2023-01-26 00:02:38 +01:00
parent 0b36781037
commit 3edea8c214

View File

@ -10,7 +10,7 @@ const timer = ms => new Promise( res => setTimeout(res, ms));
const analyser = new LinkAnalyser();
const db = await dbConnection();
while (true) {
const chunk = await db.all(SQL`SELECT url FROM links WHERE (expiresAt IS NULL OR expiresAt <= ${new Date() / 1000}) LIMIT 64`);
const chunk = await db.all(SQL`SELECT url FROM links WHERE (expiresAt IS NULL OR expiresAt <= ${new Date() / 1000}) ORDER BY RANDOM() LIMIT 64`);
console.log(`Fetching ${chunk.length} links: (${chunk.map(l => l.url).join(', ')})`);
if (chunk.length === 0) {
await timer(1000);