work on qm spider
This commit is contained in:
parent
b767689470
commit
1d62343051
7 changed files with 333 additions and 146 deletions
|
|
@ -4,7 +4,7 @@ import {
|
|||
Operation,
|
||||
ScheduledOperation,
|
||||
} from '@stock-bot/handlers';
|
||||
import { checkSessions, createSession } from './actions';
|
||||
import { checkSessions, createSession, searchSymbols, spiderSymbolSearch } from './actions';
|
||||
|
||||
@Handler('qm')
|
||||
export class QMHandler extends BaseHandler {
|
||||
|
|
@ -14,7 +14,7 @@ export class QMHandler extends BaseHandler {
|
|||
|
||||
@ScheduledOperation('check-sessions', '*/2 * * * *', {
|
||||
priority: 8,
|
||||
immediately: true,
|
||||
immediately: false,
|
||||
description: 'Check and maintain QM sessions every 2 minutes',
|
||||
})
|
||||
checkSessions = checkSessions;
|
||||
|
|
@ -22,79 +22,16 @@ export class QMHandler extends BaseHandler {
|
|||
@Operation('create-session')
|
||||
createSession = createSession;
|
||||
|
||||
// @Operation('search-symbols')
|
||||
// async searchSymbols(_input: unknown, _context: ExecutionContext): Promise<unknown> {
|
||||
// this.logger.info('Searching QM symbols with new DI pattern...');
|
||||
// try {
|
||||
// // Check existing symbols in MongoDB
|
||||
// const symbolsCollection = this.mongodb.collection('qm_symbols');
|
||||
// const symbols = await symbolsCollection.find({}).limit(100).toArray();
|
||||
@ScheduledOperation('spider-symbol-search', '* * * * *', {
|
||||
priority: 8,
|
||||
immediately: false,
|
||||
description: 'Weekly comprehensive symbol search using QM API spider - runs every Saturday at midnight'
|
||||
})
|
||||
spiderSymbolSchedule = spiderSymbolSearch;
|
||||
|
||||
// this.logger.info('QM symbol search completed', { count: symbols.length });
|
||||
@Operation('spider-symbols')
|
||||
spiderSymbolsJob = spiderSymbolSearch;
|
||||
|
||||
// if (symbols && symbols.length > 0) {
|
||||
// // Cache result for performance
|
||||
// await this.cache.set('qm-symbols-sample', symbols.slice(0, 10), 1800);
|
||||
|
||||
// return {
|
||||
// success: true,
|
||||
// message: 'QM symbol search completed successfully',
|
||||
// count: symbols.length,
|
||||
// symbols: symbols.slice(0, 10), // Return first 10 symbols as sample
|
||||
// };
|
||||
// } else {
|
||||
// // No symbols found - this is expected initially
|
||||
// this.logger.info('No QM symbols found in database yet');
|
||||
// return {
|
||||
// success: true,
|
||||
// message: 'No symbols found yet - database is empty',
|
||||
// count: 0,
|
||||
// };
|
||||
// }
|
||||
|
||||
// } catch (error) {
|
||||
// this.logger.error('Failed to search QM symbols', { error });
|
||||
// throw error;
|
||||
// }
|
||||
// }
|
||||
|
||||
// @Operation('spider-symbol-search')
|
||||
// @QueueSchedule('0 0 * * 0', {
|
||||
// priority: 10,
|
||||
// immediately: false,
|
||||
// description: 'Comprehensive symbol search using QM API'
|
||||
// })
|
||||
// async spiderSymbolSearch(payload: SymbolSpiderJob | undefined, context: ExecutionContext): Promise<unknown> {
|
||||
// // Set default payload for scheduled runs
|
||||
// const jobPayload: SymbolSpiderJob = payload || {
|
||||
// prefix: null,
|
||||
// depth: 1,
|
||||
// source: 'qm',
|
||||
// maxDepth: 4
|
||||
// };
|
||||
|
||||
// this.logger.info('Starting QM spider symbol search', { payload: jobPayload });
|
||||
|
||||
// // Store spider job info in cache (temporary data)
|
||||
// const spiderJobId = `spider:qm:${Date.now()}:${Math.random().toString(36).substr(2, 9)}`;
|
||||
// const spiderResult = {
|
||||
// payload: jobPayload,
|
||||
// startTime: new Date().toISOString(),
|
||||
// status: 'started',
|
||||
// jobId: spiderJobId
|
||||
// };
|
||||
|
||||
// // Store in cache with 1 hour TTL (temporary data)
|
||||
// await this.cache.set(spiderJobId, spiderResult, 3600);
|
||||
// this.logger.debug('Spider job stored in cache', { spiderJobId, ttl: 3600 });
|
||||
|
||||
// // Schedule follow-up processing if needed
|
||||
// await this.scheduleOperation('search-symbols', { source: 'spider', spiderJobId }, { delay: 5000 });
|
||||
|
||||
// return {
|
||||
// success: true,
|
||||
// message: 'QM spider search initiated',
|
||||
// spiderJobId
|
||||
// };
|
||||
// }
|
||||
@Operation('search-symbols')
|
||||
searchSymbols = searchSymbols;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue