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
const exchanges: Exchange[] = [];
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({
exchange: symbol.exchange,
exchangeCode: symbol.exchangeCode || '',
exchangeShortName: symbol.exchangeShortName || '',
exchange: symbol.exchangeCode,
exchangeName: symbol.exchangeShortName || '',
countryCode: symbol.countryCode || '',
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) {
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) {
update.$set[`operations.${operation}.lastRecordDate`] = data.lastRecordDate;
}
@ -208,8 +218,8 @@ export class QMOperationTracker {
const filter: any = {
$or: [
{ [`operations.${operationName}.lastRunAt`]: { $lt: cutoffDate } },
{ [`operations.${operationName}.lastRunAt`]: { $exists: false } },
{ [`operations.${operationName}.lastSuccessAt`]: { $lt: cutoffDate } },
{ [`operations.${operationName}.lastSuccessAt`]: { $exists: false } },
{ [`operations.${operationName}`]: { $exists: false } }
]
};
@ -221,7 +231,7 @@ export class QMOperationTracker {
const symbols = await this.mongodb.find(this.collectionName, filter, {
limit,
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);

View file

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