initial data-ingestion refactor

This commit is contained in:
Boki 2025-06-21 15:18:25 -04:00
parent 09d907a10c
commit 4f89affc2b
19 changed files with 309 additions and 549 deletions

View file

@ -4,12 +4,13 @@ import {
handlerRegistry,
type HandlerConfigWithSchedule
} from '@stock-bot/queue';
import type { ServiceContainer } from '@stock-bot/connection-factory';
import type { SymbolSpiderJob } from './shared/types';
const handlerLogger = getLogger('qm-handler');
// Initialize and register the QM provider
export function initializeQMProvider() {
export function initializeQMProvider(container: ServiceContainer) {
handlerLogger.debug('Registering QM provider with scheduled jobs...');
const qmProviderConfig: HandlerConfigWithSchedule = {
@ -17,12 +18,12 @@ export function initializeQMProvider() {
operations: {
'create-sessions': createJobHandler(async () => {
const { createSessions } = await import('./operations/session.operations');
await createSessions();
await createSessions(container);
return { success: true, message: 'QM sessions created successfully' };
}),
'search-symbols': createJobHandler(async () => {
const { fetchSymbols } = await import('./operations/symbols.operations');
const symbols = await fetchSymbols();
const symbols = await fetchSymbols(container);
if (symbols && symbols.length > 0) {
return {
@ -41,9 +42,7 @@ export function initializeQMProvider() {
}),
'spider-symbol-search': createJobHandler(async (payload: SymbolSpiderJob) => {
const { spiderSymbolSearch } = await import('./operations/spider.operations');
const result = await spiderSymbolSearch(payload);
return result;
return await spiderSymbolSearch(payload, container);
}),
},