work on qm

This commit is contained in:
Boki 2025-06-29 10:00:29 -04:00
parent 6082a54d14
commit 5640444c47
9 changed files with 492 additions and 476 deletions

View file

@ -30,6 +30,7 @@ export async function updateFinancials(
input: {
symbol: string;
symbolId: number;
qmSearchCode: string;
},
_context?: ExecutionContext
): Promise<{
@ -38,7 +39,7 @@ export async function updateFinancials(
message: string;
data?: any;
}> {
const { symbol, symbolId } = input;
const { symbol, symbolId, qmSearchCode } = input;
this.logger.info('Fetching financials', { symbol, symbolId });
@ -96,7 +97,7 @@ export async function updateFinancials(
// Update symbol to track last financials update
const tracker = await getOperationTracker(this);
await tracker.updateSymbolOperation(symbol, 'financials_update', {
await tracker.updateSymbolOperation(qmSearchCode, 'financials_update', {
status: 'success',
lastRecordDate: new Date(),
recordCount: financialData.length
@ -135,7 +136,7 @@ export async function updateFinancials(
// Track failure
const tracker = await getOperationTracker(this);
await tracker.updateSymbolOperation(symbol, 'financials_update', {
await tracker.updateSymbolOperation(qmSearchCode, 'financials_update', {
status: 'failure',
});
@ -187,9 +188,9 @@ export async function scheduleFinancialsUpdates(
// Get full symbol data to include symbolId
const symbolDocs = await this.mongodb.find('qmSymbols', {
symbol: { $in: staleSymbols }
qmSearchCode: { $in: staleSymbols }
}, {
projection: { symbol: 1, symbolId: 1 }
projection: { symbol: 1, symbolId: 1, qmSearchCode: 1 }
});
let queued = 0;
@ -205,7 +206,8 @@ export async function scheduleFinancialsUpdates(
await this.scheduleOperation('update-financials', {
symbol: doc.symbol,
symbolId: doc.symbolId
symbolId: doc.symbolId,
qmSearchCode: doc.qmSearchCode
}, {
priority: 4,
delay: queued * 2000 // 2 seconds between jobs