feat(laws,opendata): add local law storage and migrate OpenData persistence to smartdb-backed local storage
This commit is contained in:
@@ -32,7 +32,17 @@ export class StockDataService {
|
||||
|
||||
private logger = console;
|
||||
|
||||
private config: Required<IStockDataServiceConfig> = {
|
||||
private config: {
|
||||
cache: {
|
||||
priceTTL: number;
|
||||
fundamentalsTTL: number;
|
||||
maxEntries: number;
|
||||
};
|
||||
timeout: {
|
||||
price: number;
|
||||
fundamentals: number;
|
||||
};
|
||||
} = {
|
||||
cache: {
|
||||
priceTTL: 24 * 60 * 60 * 1000, // 24 hours
|
||||
fundamentalsTTL: 90 * 24 * 60 * 60 * 1000, // 90 days
|
||||
@@ -200,7 +210,7 @@ export class StockDataService {
|
||||
entry.lastErrorTime = new Date();
|
||||
lastError = error as Error;
|
||||
|
||||
console.warn(`Provider ${provider.name} failed for ${ticker}: ${error.message}`);
|
||||
console.warn(`Provider ${provider.name} failed for ${ticker}: ${plugins.getErrorMessage(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,7 +260,7 @@ export class StockDataService {
|
||||
entry.lastErrorTime = new Date();
|
||||
lastError = error as Error;
|
||||
|
||||
console.warn(`Provider ${provider.name} failed for batch prices: ${error.message}`);
|
||||
console.warn(`Provider ${provider.name} failed for batch prices: ${plugins.getErrorMessage(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +311,7 @@ export class StockDataService {
|
||||
entry.lastErrorTime = new Date();
|
||||
lastError = error as Error;
|
||||
|
||||
console.warn(`Provider ${provider.name} failed for ${ticker} fundamentals: ${error.message}`);
|
||||
console.warn(`Provider ${provider.name} failed for ${ticker} fundamentals: ${plugins.getErrorMessage(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -352,7 +362,7 @@ export class StockDataService {
|
||||
entry.lastErrorTime = new Date();
|
||||
lastError = error as Error;
|
||||
|
||||
console.warn(`Provider ${provider.name} failed for batch fundamentals: ${error.message}`);
|
||||
console.warn(`Provider ${provider.name} failed for batch fundamentals: ${plugins.getErrorMessage(error)}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -382,7 +392,7 @@ export class StockDataService {
|
||||
fundamentals = this.enrichWithPrice(fundamentals, price.price);
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`Failed to fetch fundamentals for ${normalizedRequest.ticker}: ${error.message}`);
|
||||
console.warn(`Failed to fetch fundamentals for ${normalizedRequest.ticker}: ${plugins.getErrorMessage(error)}`);
|
||||
// Continue without fundamentals
|
||||
}
|
||||
}
|
||||
@@ -426,7 +436,7 @@ export class StockDataService {
|
||||
fundamentalsMap = new Map(fundamentals.map(f => [f.ticker, f]));
|
||||
}
|
||||
} catch (error) {
|
||||
console.warn(`Failed to fetch batch fundamentals: ${error.message}`);
|
||||
console.warn(`Failed to fetch batch fundamentals: ${plugins.getErrorMessage(error)}`);
|
||||
// Continue without fundamentals
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user