work on refactoring operation tracker
This commit is contained in:
parent
cbf002a31a
commit
c24e551734
11 changed files with 121 additions and 145 deletions
|
|
@ -147,7 +147,7 @@ export class OperationRegistry {
|
|||
providerName: string,
|
||||
operationName: string,
|
||||
options?: StaleSymbolOptions
|
||||
): Promise<string[]> {
|
||||
): Promise<Array<{ symbol: any; lastRun?: Date; lastSuccess?: Date; operations?: any }>> {
|
||||
const tracker = this.getTracker(providerName);
|
||||
return tracker.getStaleSymbols(operationName, options);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -312,7 +312,7 @@ export class OperationTracker {
|
|||
async getStaleSymbols(
|
||||
operationName: string,
|
||||
options: StaleSymbolOptions = {}
|
||||
): Promise<string[]> {
|
||||
): Promise<Array<{ symbol: any; lastRun?: Date; lastSuccess?: Date; operations?: any }>> {
|
||||
const { collectionName, symbolField } = this.provider.getProviderConfig();
|
||||
const {
|
||||
limit = 1000,
|
||||
|
|
@ -353,11 +353,16 @@ export class OperationTracker {
|
|||
|
||||
const symbols = await this.mongodb.find(collectionName, filter, {
|
||||
limit,
|
||||
projection: { [symbolField]: 1 },
|
||||
projection: { }, // Return all fields
|
||||
sort: { [`operations.${operationName}.lastSuccessAt`]: 1 }
|
||||
});
|
||||
|
||||
return symbols.map(doc => doc[symbolField]);
|
||||
return symbols.map(doc => ({
|
||||
symbol: doc,
|
||||
lastRun: doc.operations?.[operationName]?.lastRunAt,
|
||||
lastSuccess: doc.operations?.[operationName]?.lastSuccessAt,
|
||||
operations: doc.operations
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue