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( export async function updateUniqueSymbols(
this: CeoHandler, this: CeoHandler,
_payload: unknown, payload: any,
_context: unknown _context: unknown
): Promise<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 { try {
// Get unique ceoId values from the ceoSymbols collection // Get unique ceoId values from the ceoSymbols collection
@ -31,6 +32,7 @@ export async function updateUniqueSymbols(
let scheduledJobs = 0; let scheduledJobs = 0;
for (const symbol of uniqueSymbols) { for (const symbol of uniqueSymbols) {
// Schedule a job to process this individual symbol // Schedule a job to process this individual symbol
if(action === 'get-posts') {
await this.scheduleOperation( await this.scheduleOperation(
'get-posts', 'get-posts',
{ {
@ -40,6 +42,18 @@ export async function updateUniqueSymbols(
}, },
{ priority: 10 } { 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++; scheduledJobs++;

View file

@ -21,13 +21,23 @@ export class CeoHandler extends BaseHandler {
}) })
getChannels = getChannels; getChannels = getChannels;
@Operation('update-unique-symbols') @Operation('update-unique-symbols-posts')
@ScheduledOperation('update-unique-symbols', '0 0 1 * *', { @ScheduledOperation('update-unique-symbols-posts', '30 * * * *', {
priority: 5, priority: 5,
immediately: false, immediately: false,
description: 'Process unique CEO symbols and schedule individual jobs', 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') @Operation('get-posts')
getPosts = getPosts; getPosts = getPosts;

View file

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