From 44c087aaae18199ddbdb388f1ad39f915cfd6198 Mon Sep 17 00:00:00 2001 From: Boki Date: Tue, 24 Jun 2025 22:55:22 -0400 Subject: [PATCH] work on ceo and extra jobs for shorts --- .../actions/update-unique-symbols.action.ts | 36 +++++++++++++------ .../src/handlers/ceo/ceo.handler.ts | 16 +++++++-- .../handlers/src/decorators/decorators.ts | 2 ++ 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/apps/stock/data-ingestion/src/handlers/ceo/actions/update-unique-symbols.action.ts b/apps/stock/data-ingestion/src/handlers/ceo/actions/update-unique-symbols.action.ts index d13d4ce..84d79e8 100644 --- a/apps/stock/data-ingestion/src/handlers/ceo/actions/update-unique-symbols.action.ts +++ b/apps/stock/data-ingestion/src/handlers/ceo/actions/update-unique-symbols.action.ts @@ -2,10 +2,11 @@ import type { CeoHandler } from '../ceo.handler'; export async function updateUniqueSymbols( this: CeoHandler, - _payload: unknown, + payload: any, _context: unknown ): Promise { - 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++; diff --git a/apps/stock/data-ingestion/src/handlers/ceo/ceo.handler.ts b/apps/stock/data-ingestion/src/handlers/ceo/ceo.handler.ts index fc0fe30..c0c2dd8 100644 --- a/apps/stock/data-ingestion/src/handlers/ceo/ceo.handler.ts +++ b/apps/stock/data-ingestion/src/handlers/ceo/ceo.handler.ts @@ -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; diff --git a/libs/core/handlers/src/decorators/decorators.ts b/libs/core/handlers/src/decorators/decorators.ts index 102bfa2..60985c7 100644 --- a/libs/core/handlers/src/decorators/decorators.ts +++ b/libs/core/handlers/src/decorators/decorators.ts @@ -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 {