mirror of
https://gitlab.com/PronounsPage/PronounsPage.git
synced 2025-09-24 05:05:20 -04:00
[profile] #290 generic rel=me (links table) - minor fixes
This commit is contained in:
parent
8607e31c63
commit
9155b1c9fe
@ -11,7 +11,7 @@ const timer = ms => new Promise( res => setTimeout(res, ms));
|
|||||||
const analyser = new LinkAnalyser();
|
const analyser = new LinkAnalyser();
|
||||||
const db = await dbConnection();
|
const db = await dbConnection();
|
||||||
while (true) {
|
while (true) {
|
||||||
const chunk = await db.all(SQL`SELECT url FROM links WHERE (expiresAt IS NULL OR expiresAt <= ${new Date() / 1000}) LIMIT 16`);
|
const chunk = await db.all(SQL`SELECT url FROM links WHERE (expiresAt IS NULL OR expiresAt <= ${new Date() / 1000}) LIMIT 64`);
|
||||||
console.log(`Fetching ${chunk.length} links: (${chunk.map(l => l.url).join(', ')})`);
|
console.log(`Fetching ${chunk.length} links: (${chunk.map(l => l.url).join(', ')})`);
|
||||||
if (chunk.length === 0) {
|
if (chunk.length === 0) {
|
||||||
await timer(1000);
|
await timer(1000);
|
||||||
@ -20,10 +20,10 @@ const timer = ms => new Promise( res => setTimeout(res, ms));
|
|||||||
const results = await Promise.all(chunk.map(({url}) => analyser.analyse(url)));
|
const results = await Promise.all(chunk.map(({url}) => analyser.analyse(url)));
|
||||||
for (let result of results) {
|
for (let result of results) {
|
||||||
if (result.error) {
|
if (result.error) {
|
||||||
await db.get(SQL`UPDATE links SET expiresAt = ${(new Date() / 1000) + 7*24*60*60} WHERE url=${result.url}`);
|
await db.get(SQL`UPDATE links SET expiresAt = ${parseInt(new Date() / 1000) + 7*24*60*60} WHERE url=${result.url}`);
|
||||||
} else {
|
} else {
|
||||||
await db.get(SQL`UPDATE links
|
await db.get(SQL`UPDATE links
|
||||||
SET expiresAt = ${(new Date() / 1000) + 7*24*60*60},
|
SET expiresAt = ${parseInt(new Date() / 1000) + 7*24*60*60},
|
||||||
favicon = ${result.favicon},
|
favicon = ${result.favicon},
|
||||||
relMe = ${JSON.stringify(result.relMe)},
|
relMe = ${JSON.stringify(result.relMe)},
|
||||||
nodeinfo = ${JSON.stringify(result.nodeinfo)}
|
nodeinfo = ${JSON.stringify(result.nodeinfo)}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user