mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
try-catch trending tags cron
This commit is contained in:
parent
5ebde99320
commit
7949c95f77
1 changed files with 29 additions and 25 deletions
|
|
@ -72,33 +72,37 @@ export async function updateTrendingTags(
|
|||
|
||||
const tagNames = aliases ? [tagName, ...aliases] : [tagName];
|
||||
|
||||
const trends = await getTrendingTagValues(kysely, tagNames, {
|
||||
kinds,
|
||||
since: yesterday,
|
||||
until: now,
|
||||
limit,
|
||||
});
|
||||
try {
|
||||
const trends = await getTrendingTagValues(kysely, tagNames, {
|
||||
kinds,
|
||||
since: yesterday,
|
||||
until: now,
|
||||
limit,
|
||||
});
|
||||
|
||||
if (!trends.length) {
|
||||
console.info(`No trending ${l} found. Skipping.`);
|
||||
return;
|
||||
if (!trends.length) {
|
||||
console.info(`No trending ${l} found. Skipping.`);
|
||||
return;
|
||||
}
|
||||
|
||||
const signer = new AdminSigner();
|
||||
|
||||
const label = await signer.signEvent({
|
||||
kind: 1985,
|
||||
content: '',
|
||||
tags: [
|
||||
['L', 'pub.ditto.trends'],
|
||||
['l', l, 'pub.ditto.trends'],
|
||||
...trends.map(({ value, authors, uses }) => [tagName, value, extra, authors.toString(), uses.toString()]),
|
||||
],
|
||||
created_at: Math.floor(Date.now() / 1000),
|
||||
});
|
||||
|
||||
await handleEvent(label, signal);
|
||||
console.info(`Trending ${l} updated.`);
|
||||
} catch (e) {
|
||||
console.error(`Error updating trending ${l}: ${e.message}`);
|
||||
}
|
||||
|
||||
const signer = new AdminSigner();
|
||||
|
||||
const label = await signer.signEvent({
|
||||
kind: 1985,
|
||||
content: '',
|
||||
tags: [
|
||||
['L', 'pub.ditto.trends'],
|
||||
['l', l, 'pub.ditto.trends'],
|
||||
...trends.map(({ value, authors, uses }) => [tagName, value, extra, authors.toString(), uses.toString()]),
|
||||
],
|
||||
created_at: Math.floor(Date.now() / 1000),
|
||||
});
|
||||
|
||||
await handleEvent(label, signal);
|
||||
console.info(`Trending ${l} updated.`);
|
||||
}
|
||||
|
||||
/** Update trending pubkeys. */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue