commit 2 refactor

This commit is contained in:
Boki 2026-10-20 14:35:45 -04:00
parent 588f666943
commit 32e43c9243
310 changed files with 33318 additions and 31189 deletions

View file

@ -1,9 +1,11 @@
import type { QueryResultRow } from 'pg';
import { at } from '@stock-bot/invariants';
import { getLogger } from '@stock-bot/logger';
import type { QueryResult, TableSchema } from './types';
// Interface to avoid circular dependency
interface QuestDBClientInterface {
query<T = any>(sql: string, params?: any[]): Promise<QueryResult<T>>;
query<T = QueryResultRow>(sql: string, params?: unknown[]): Promise<QueryResult<T>>;
}
/**
@ -215,7 +217,7 @@ export class QuestDBSchemaManager {
WHERE table_name = '${tableName}'
`);
return result.rows.length > 0 && result.rows[0].count > 0;
return result.rows.length > 0 && at(result.rows, 0).count > 0;
} catch (error) {
this.logger.error(`Error checking if table exists: ${tableName}`, error);
return false;
@ -266,7 +268,7 @@ export class QuestDBSchemaManager {
/**
* Get table statistics
*/
public async getTableStats(tableName: string): Promise<any> {
public async getTableStats(tableName: string): Promise<QueryResultRow | undefined> {
try {
const result = await this.client.query(`
SELECT