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 updateFilings(
input: {
symbol: string;
symbolId: number;
qmSearchCode: string;
},
_context?: ExecutionContext
): Promise<{
@ -38,7 +39,7 @@ export async function updateFilings(
message: string;
data?: any;
}> {
const { symbol, symbolId } = input;
const { symbol, symbolId, qmSearchCode } = input;
this.logger.info('Fetching filings', { symbol, symbolId });
@ -97,7 +98,7 @@ export async function updateFilings(
// Update symbol to track last filings update
const tracker = await getOperationTracker(this);
await tracker.updateSymbolOperation(symbol, 'filings_update', {
await tracker.updateSymbolOperation(qmSearchCode, 'filings_update', {
status: 'success',
lastRecordDate: new Date(),
recordCount: filingsData.length
@ -117,7 +118,7 @@ export async function updateFilings(
} else {
// Some symbols may not have filings (non-US companies, etc)
const tracker = await getOperationTracker(this);
await tracker.updateSymbolOperation(symbol, 'filings_update', {
await tracker.updateSymbolOperation(qmSearchCode, 'filings_update', {
status: 'success',
lastRecordDate: new Date(),
recordCount: 0
@ -145,7 +146,7 @@ export async function updateFilings(
// Track failure
const tracker = await getOperationTracker(this);
await tracker.updateSymbolOperation(symbol, 'filings_update', {
await tracker.updateSymbolOperation(qmSearchCode, 'filings_update', {
status: 'failure'
});
@ -197,9 +198,9 @@ export async function scheduleFilingsUpdates(
// 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;
@ -215,7 +216,8 @@ export async function scheduleFilingsUpdates(
await this.scheduleOperation('update-filings', {
symbol: doc.symbol,
symbolId: doc.symbolId
symbolId: doc.symbolId,
qmSearchCode: doc.qmSearchCode
}, {
priority: 5, // Lower priority than financial data
delay: queued * 2000 // 2 seconds between jobs