From fabf42dc7fcd94990808443e45bc53d9793b8365 Mon Sep 17 00:00:00 2001 From: Boki Date: Sun, 22 Jun 2025 12:09:03 -0400 Subject: [PATCH] work on ceo initial symbol and exchanges - pretty much done --- .../data-ingestion/src/handlers/ceo/ceo.handler.ts | 14 ++++++++++---- libs/utils/src/fetch.ts | 2 +- tsconfig.json | 1 + 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/apps/data-ingestion/src/handlers/ceo/ceo.handler.ts b/apps/data-ingestion/src/handlers/ceo/ceo.handler.ts index a0c1a9c..beb156e 100644 --- a/apps/data-ingestion/src/handlers/ceo/ceo.handler.ts +++ b/apps/data-ingestion/src/handlers/ceo/ceo.handler.ts @@ -2,23 +2,22 @@ import { BaseHandler, Handler, ScheduledOperation, - type ExecutionContext, type IServiceContainer } from '@stock-bot/handlers'; import { fetch, getRandomUserAgent } from '@stock-bot/utils'; -@Handler('qm') +@Handler('ceo') export class CeoHandler extends BaseHandler { constructor(services: IServiceContainer) { super(services); // Handler name read from @Handler decorator } - @ScheduledOperation('ceo', '0 */15 * * *', { + @ScheduledOperation('update-ceo-channels', '0 */15 * * *', { priority: 7, immediately: true, description: 'Get all CEO symbols and exchanges' }) - async searchCeoChannels(payload: number | undefined, context: ExecutionContext): Promise { + async updateCeoChannels(payload: number | undefined): Promise { const proxy = this.proxy.getProxy();; let page; if(payload === undefined) { @@ -67,6 +66,13 @@ export class CeoHandler extends BaseHandler { await this.mongodb.batchUpsert('ceoSymbols', symbols, ['symbol', 'exchange']); await this.mongodb.batchUpsert('ceoExchanges', exchanges, ['exchange']); + + if(page === 1) { + for( let i = 2; i <= totalPages; i++) { + this.logger.info(`Scheduling next page ${i} for CEO channels`); + this.scheduleOperation('update-ceo-channels', i) + } + } this.logger.info(`Fetched CEO channels for page ${page}/${totalPages}`); return { page, totalPages }; diff --git a/libs/utils/src/fetch.ts b/libs/utils/src/fetch.ts index 4fd642d..1c80867 100644 --- a/libs/utils/src/fetch.ts +++ b/libs/utils/src/fetch.ts @@ -63,7 +63,7 @@ export async function fetch( async function performFetch( input: RequestInfo | URL, requestOptions: RequestInit, - logger: Logger, + logger: any, url: string ): Promise { logger.debug('HTTP request', { diff --git a/tsconfig.json b/tsconfig.json index f18334c..23d15aa 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,7 @@ { "$schema": "https://json.schemastore.org/tsconfig", "compilerOptions": { + "types": ["bun-types"], // JavaScript output target version "target": "ES2022", // Module configuration for different project types