updated exchanges

This commit is contained in:
Boki 2025-06-29 13:16:43 -04:00
parent 0b33e9a8b6
commit 44fa3e8c0c
3 changed files with 17 additions and 9 deletions

View file

@ -73,11 +73,10 @@ export async function spiderSymbol(
// Extract and store unique exchanges // Extract and store unique exchanges
const exchanges: Exchange[] = []; const exchanges: Exchange[] = [];
for (const symbol of symbols) { for (const symbol of symbols) {
if (symbol.exchange && !exchanges.some(ex => ex.exchange === symbol.exchange)) { if (symbol.exchangeCode && !exchanges.some(ex => ex.exchange === symbol.exchangeCode)) {
exchanges.push({ exchanges.push({
exchange: symbol.exchange, exchange: symbol.exchangeCode,
exchangeCode: symbol.exchangeCode || '', exchangeName: symbol.exchangeShortName || '',
exchangeShortName: symbol.exchangeShortName || '',
countryCode: symbol.countryCode || '', countryCode: symbol.countryCode || '',
source: 'qm', source: 'qm',
}); });

View file

@ -101,6 +101,11 @@ export class QMOperationTracker {
} }
}; };
// Only update lastSuccessAt on successful operations
if (data.status === 'success') {
update.$set[`operations.${operationName}.lastSuccessAt`] = new Date();
}
if (data.lastRecordDate) { if (data.lastRecordDate) {
update.$set[`operations.${operationName}.lastRecordDate`] = data.lastRecordDate; update.$set[`operations.${operationName}.lastRecordDate`] = data.lastRecordDate;
} }
@ -151,6 +156,11 @@ export class QMOperationTracker {
} }
}; };
// Only update lastSuccessAt on successful operations
if (data.status === 'success') {
update.$set[`operations.${operation}.lastSuccessAt`] = new Date();
}
if (data.lastRecordDate) { if (data.lastRecordDate) {
update.$set[`operations.${operation}.lastRecordDate`] = data.lastRecordDate; update.$set[`operations.${operation}.lastRecordDate`] = data.lastRecordDate;
} }
@ -208,8 +218,8 @@ export class QMOperationTracker {
const filter: any = { const filter: any = {
$or: [ $or: [
{ [`operations.${operationName}.lastRunAt`]: { $lt: cutoffDate } }, { [`operations.${operationName}.lastSuccessAt`]: { $lt: cutoffDate } },
{ [`operations.${operationName}.lastRunAt`]: { $exists: false } }, { [`operations.${operationName}.lastSuccessAt`]: { $exists: false } },
{ [`operations.${operationName}`]: { $exists: false } } { [`operations.${operationName}`]: { $exists: false } }
] ]
}; };
@ -221,7 +231,7 @@ export class QMOperationTracker {
const symbols = await this.mongodb.find(this.collectionName, filter, { const symbols = await this.mongodb.find(this.collectionName, filter, {
limit, limit,
projection: { qmSearchCode: 1 }, projection: { qmSearchCode: 1 },
sort: { [`operations.${operationName}.lastRunAt`]: 1 } // Oldest first sort: { [`operations.${operationName}.lastSuccessAt`]: 1 } // Oldest successful run first
}); });
return symbols.map(s => s.qmSearchCode); return symbols.map(s => s.qmSearchCode);

View file

@ -21,8 +21,7 @@ export interface SymbolSpiderJob {
export interface Exchange { export interface Exchange {
exchange: string; exchange: string;
exchangeCode: string; exchangeName: string;
exchangeShortName: string;
countryCode: string; countryCode: string;
source: string; source: string;
} }