fixes
This commit is contained in:
parent
c6c55e2979
commit
acf66dbfb6
3 changed files with 13 additions and 10 deletions
|
|
@ -4,7 +4,7 @@ import {
|
|||
ScheduledOperation,
|
||||
type IServiceContainer
|
||||
} from '@stock-bot/handlers';
|
||||
import { fetch, getRandomUserAgent } from '@stock-bot/utils';
|
||||
import { getRandomUserAgent } from '@stock-bot/utils';
|
||||
|
||||
@Handler('ceo')
|
||||
export class CeoHandler extends BaseHandler {
|
||||
|
|
@ -17,18 +17,22 @@ export class CeoHandler extends BaseHandler {
|
|||
immediately: true,
|
||||
description: 'Get all CEO symbols and exchanges'
|
||||
})
|
||||
async updateCeoChannels(payload: number | undefined): Promise<unknown> {
|
||||
const proxy = this.proxy.getProxy();;
|
||||
async updateCeoChannels(payload: number | undefined, handler: BaseHandler): Promise<unknown> {
|
||||
const proxy = this.proxy?.getProxy();
|
||||
if(!proxy) {
|
||||
this.logger.warn('No proxy available for CEO channels update');
|
||||
return;
|
||||
}
|
||||
let page;
|
||||
if(payload === undefined) {
|
||||
page = 1
|
||||
}else{
|
||||
page = payload;
|
||||
}
|
||||
|
||||
|
||||
this.logger.info(`Fetching CEO channels for page ${page} with proxy ${proxy}`);
|
||||
const response = await fetch('https://api.ceo.ca/api/home?exchange=all&sort_by=symbol§or=All&tab=companies&page='+page, {
|
||||
method: 'GET',
|
||||
const response = await this.http.get('https://api.ceo.ca/api/home?exchange=all&sort_by=symbol§or=All&tab=companies&page='+page, {
|
||||
proxy: proxy,
|
||||
headers: {
|
||||
'User-Agent': getRandomUserAgent()
|
||||
|
|
@ -69,7 +73,7 @@ export class CeoHandler extends BaseHandler {
|
|||
|
||||
if(page === 1) {
|
||||
for( let i = 2; i <= totalPages; i++) {
|
||||
this.logger.info(`Scheduling next page ${i} for CEO channels`);
|
||||
this.logger.info(`Scheduling page ${i} of ${totalPages} for CEO channels`);
|
||||
this.scheduleOperation('update-ceo-channels', i)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,10 +114,9 @@ async function initializeServices() {
|
|||
logger.debug('Initializing data handlers with Awilix DI pattern...');
|
||||
|
||||
// Auto-register all handlers with the service container from Awilix
|
||||
// TODO: Fix handler registration
|
||||
// await initializeAllHandlers(serviceContainer);
|
||||
await initializeAllHandlers(serviceContainer);
|
||||
|
||||
logger.info('Data handlers initialization skipped for testing');
|
||||
logger.info('Data handlers initialized with new DI pattern');
|
||||
|
||||
// Create scheduled jobs from registered handlers
|
||||
logger.debug('Creating scheduled jobs from registered handlers...');
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import type { Logger } from '@stock-bot/core/logger';
|
||||
import { Collection, Db, MongoClient } from 'mongodb';
|
||||
import type { OptionalUnlessRequiredId } from 'mongodb';
|
||||
import { Collection, Db, MongoClient } from 'mongodb';
|
||||
import type { ConnectionEvents, DocumentBase, DynamicPoolConfig, MongoDBClientConfig, PoolMetrics } from './types';
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue