fix (ornith-35): watchlistRepository double-encoding bug — single JSON.stringify, 13/13 tests pass
This commit is contained in:
@@ -105,7 +105,7 @@ export class OptionsAdapter implements SourceFetch {
|
||||
const dates = [...rawDates].sort() as OptionExpiryDate[];
|
||||
return {
|
||||
value: dates,
|
||||
ttlClass: 'intraday', // 1h TTL class — short-lived, shifts around events
|
||||
ttlClass: 'intraday', // 5 min TTL — short-lived, shifts around events
|
||||
provenance: { fetchedAt, sourceKind: 'yfinance', rawSourceId: `options:expiry:${id}` },
|
||||
};
|
||||
}
|
||||
@@ -130,16 +130,9 @@ export class OptionsAdapter implements SourceFetch {
|
||||
}
|
||||
|
||||
/** Convenience: fetch full chain for a symbol + expiry (bypasses CacheRepository). */
|
||||
async chain(symbol: string, expiry?: string): Promise<OptionChain> {
|
||||
const key = expiry
|
||||
? `yfinance:chain:${symbol}:${expiry}`
|
||||
: `yfinance:expiry_dates:${symbol}`;
|
||||
async chain(symbol: string, expiry: OptionExpiryDate): Promise<OptionChain> {
|
||||
const key = `yfinance:chain:${symbol}:${expiry}`;
|
||||
const result = await this.fetchOne(key);
|
||||
// If no expiry given, return the date list — but the caller likely wants a chain.
|
||||
if (typeof result.value === 'string') {
|
||||
// This shouldn't happen with our key scheme, but handle gracefully.
|
||||
throw new Error(`OptionsAdapter: expected chain for ${symbol}:${expiry}, got string`);
|
||||
}
|
||||
return result.value as OptionChain;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user