fixed libs ready for new data-injection
This commit is contained in:
parent
c5a114d544
commit
8405f44bd9
25 changed files with 277 additions and 241 deletions
|
|
@ -3,11 +3,10 @@ import {
|
|||
Handler,
|
||||
Operation,
|
||||
QueueSchedule,
|
||||
handlerRegistry,
|
||||
createJobHandler,
|
||||
type ExecutionContext,
|
||||
type HandlerConfigWithSchedule
|
||||
} from '@stock-bot/handlers';
|
||||
import { handlerRegistry, createJobHandler } from '@stock-bot/types';
|
||||
import type { IDataIngestionServices, IExecutionContext } from '@stock-bot/di';
|
||||
import type { SymbolSpiderJob } from './shared/types';
|
||||
|
||||
|
|
@ -87,25 +86,26 @@ export class QMHandler extends BaseHandler {
|
|||
async spiderSymbolSearch(payload: SymbolSpiderJob, context: ExecutionContext): Promise<unknown> {
|
||||
this.logger.info('Starting QM spider symbol search', { payload });
|
||||
|
||||
// Direct access to typed dependencies
|
||||
const spiderCollection = this.mongodb.collection('qm_spider_results');
|
||||
|
||||
// Store spider job info
|
||||
// Store spider job info in cache (temporary data)
|
||||
const spiderJobId = `spider:qm:${Date.now()}:${Math.random().toString(36).substr(2, 9)}`;
|
||||
const spiderResult = {
|
||||
payload,
|
||||
startTime: new Date(),
|
||||
status: 'started'
|
||||
startTime: new Date().toISOString(),
|
||||
status: 'started',
|
||||
jobId: spiderJobId
|
||||
};
|
||||
|
||||
await spiderCollection.insertOne(spiderResult);
|
||||
// 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' }, 5000);
|
||||
await this.scheduleOperation('search-symbols', { source: 'spider', spiderJobId }, 5000);
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: 'QM spider search initiated',
|
||||
spiderJobId: spiderResult._id
|
||||
spiderJobId
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue