trends: Deno.cron try/catch

This commit is contained in:
Alex Gleason 2024-07-23 22:19:10 -05:00
parent 64eeee5ff7
commit 5ebde99320
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7
2 changed files with 14 additions and 4 deletions

2
deno.lock generated
View file

@ -148,7 +148,9 @@
"@nostrify/nostrify@0.27.0-rc.3": {
"integrity": "0cd3d26bb0d797e95e74b301efc85f4262bd913df12644ff42494a97a02a6c0d",
"dependencies": [
"jsr:@std/crypto@^0.224.0",
"jsr:@std/encoding@^0.224.1",
"npm:@scure/base@^1.1.6",
"npm:@scure/bip32@^1.4.0",
"npm:@scure/bip39@^1.3.0",
"npm:kysely@^0.27.3",

View file

@ -12,8 +12,12 @@ import { renderStatus } from '@/views/mastodon/statuses.ts';
let trendingHashtagsCache = getTrendingHashtags();
Deno.cron('update trending hashtags cache', '35 * * * *', async () => {
try {
const trends = await getTrendingHashtags();
trendingHashtagsCache = Promise.resolve(trends);
} catch (e) {
console.error(e);
}
});
const trendingTagsQuerySchema = z.object({
@ -51,8 +55,12 @@ async function getTrendingHashtags() {
let trendingLinksCache = getTrendingLinks();
Deno.cron('update trending links cache', '50 * * * *', async () => {
try {
const trends = await getTrendingLinks();
trendingLinksCache = Promise.resolve(trends);
} catch (e) {
console.error(e);
}
});
const trendingLinksController: AppController = async (c) => {