updateTrendingTags: accept limit param

This commit is contained in:
Alex Gleason 2024-06-02 19:27:44 -05:00
parent b35090ef10
commit 3373673706
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 4 additions and 4 deletions

View File

@ -46,7 +46,7 @@ async function updateTrendingNotes() {
console.info('Trending notes updated.'); console.info('Trending notes updated.');
} }
async function updateTrendingTags(tagName: string, extra = '') { async function updateTrendingTags(tagName: string, limit: number, extra = '') {
console.info(`Updating trending #${tagName}...`); console.info(`Updating trending #${tagName}...`);
const kysely = await DittoDB.getInstance(); const kysely = await DittoDB.getInstance();
const signal = AbortSignal.timeout(1000); const signal = AbortSignal.timeout(1000);
@ -57,7 +57,7 @@ async function updateTrendingTags(tagName: string, extra = '') {
const trends = await getTrendingTagValues(kysely, tagName, { const trends = await getTrendingTagValues(kysely, tagName, {
since: yesterday, since: yesterday,
until: now, until: now,
limit: 20, limit,
}); });
if (!trends.length) { if (!trends.length) {
@ -84,6 +84,6 @@ async function updateTrendingTags(tagName: string, extra = '') {
/** Start cron jobs for the application. */ /** Start cron jobs for the application. */
export function cron() { export function cron() {
Deno.cron('update trending notes', '15 * * * *', updateTrendingNotes); Deno.cron('update trending notes', '15 * * * *', updateTrendingNotes);
Deno.cron('update trending hashtags', '30 * * * *', () => updateTrendingTags('t')); Deno.cron('update trending hashtags', '30 * * * *', () => updateTrendingTags('t', 20));
Deno.cron('update trending links', '45 * * * *', () => updateTrendingTags('r')); Deno.cron('update trending links', '45 * * * *', () => updateTrendingTags('r', 20));
} }