work on ceo and extra jobs for shorts

This commit is contained in:
Boki 2025-06-24 22:55:22 -04:00
parent b30c79542b
commit 44c087aaae
3 changed files with 40 additions and 14 deletions

View file

@ -2,10 +2,11 @@ import type { CeoHandler } from '../ceo.handler';
export async function updateUniqueSymbols(
this: CeoHandler,
_payload: unknown,
payload: any,
_context: unknown
): Promise<unknown> {
this.logger.info('Starting update to get unique CEO symbols by ceoId');
const action = payload?.action || 'get-posts'; // Default to get-posts if no action specified
this.logger.info(`Starting update to get unique CEO symbols by ceoId for action: ${action}`);
try {
// Get unique ceoId values from the ceoSymbols collection
@ -31,15 +32,28 @@ export async function updateUniqueSymbols(
let scheduledJobs = 0;
for (const symbol of uniqueSymbols) {
// Schedule a job to process this individual symbol
await this.scheduleOperation(
'get-posts',
{
ceoId: symbol.ceoId,
symbol: symbol.symbol,
finished: symbol.finished || false,
},
{ priority: 10 }
);
if(action === 'get-posts') {
await this.scheduleOperation(
'get-posts',
{
ceoId: symbol.ceoId,
symbol: symbol.symbol,
finished: symbol.finished || false,
},
{ priority: 10 }
);
} else if(action === 'get-shorts') {
await this.scheduleOperation(
'get-shorts',
{
ceoId: symbol.ceoId,
symbol: symbol.symbol,
finished: symbol.finished || false,
},
{ priority: 10 }
);
}
scheduledJobs++;

View file

@ -21,13 +21,23 @@ export class CeoHandler extends BaseHandler {
})
getChannels = getChannels;
@Operation('update-unique-symbols')
@ScheduledOperation('update-unique-symbols', '0 0 1 * *', {
@Operation('update-unique-symbols-posts')
@ScheduledOperation('update-unique-symbols-posts', '30 * * * *', {
priority: 5,
immediately: false,
description: 'Process unique CEO symbols and schedule individual jobs',
payload: { action: 'get-posts' }
})
updateUniqueSymbols = updateUniqueSymbols;
updateUniqueSymbolsPosts = updateUniqueSymbols;
@Operation('update-unique-symbols-shorts')
@ScheduledOperation('update-unique-symbols-shorts', '0 0 * * *', {
priority: 5,
immediately: false,
description: 'Process unique CEO symbols and schedule individual jobs',
payload: { action: 'get-posts' }
})
updateUniqueSymbolsShots = updateUniqueSymbols;
@Operation('get-posts')
getPosts = getPosts;

View file

@ -46,6 +46,7 @@ export function QueueSchedule(
priority?: number;
immediately?: boolean;
description?: string;
payload?: any;
}
): any {
return function (target: any, methodName: string, descriptor?: PropertyDescriptor): any {
@ -92,6 +93,7 @@ export function ScheduledOperation(
priority?: number;
immediately?: boolean;
description?: string;
payload?: any;
}
): any {
return function (target: any, methodName: string, descriptor?: PropertyDescriptor): any {