refactored monorepo for more projects
This commit is contained in:
parent
4632c174dc
commit
9492f1b15e
180 changed files with 1438 additions and 424 deletions
|
|
@ -0,0 +1,31 @@
|
|||
import { getLogger } from '@stock-bot/logger';
|
||||
import type { IServiceContainer } from '@stock-bot/handlers';
|
||||
import type { JobPayload } from '../../../types/job-payloads';
|
||||
|
||||
const logger = getLogger('enhanced-sync-exchange-stats');
|
||||
|
||||
export async function getExchangeStats(
|
||||
payload: JobPayload,
|
||||
container: IServiceContainer
|
||||
): Promise<any> {
|
||||
logger.info('Getting exchange statistics...');
|
||||
|
||||
try {
|
||||
const postgresClient = container.postgres;
|
||||
const query = `
|
||||
SELECT
|
||||
COUNT(*) as total_exchanges,
|
||||
COUNT(CASE WHEN active = true THEN 1 END) as active_exchanges,
|
||||
COUNT(DISTINCT country) as countries,
|
||||
COUNT(DISTINCT currency) as currencies
|
||||
FROM exchanges
|
||||
`;
|
||||
const result = await postgresClient.query(query);
|
||||
|
||||
logger.info('Retrieved exchange statistics');
|
||||
return result.rows[0];
|
||||
} catch (error) {
|
||||
logger.error('Failed to get exchange statistics', { error });
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue