perf: start bond search prices with details (WealthLedger/backend#71) #89

Merged
codex-bot merged 1 commits from fix/71-bond-search-parallel-prices into develop 2026-10-14 14:04:08 +03:00
@@ -304,16 +304,18 @@ export class CatalogDiscoveryService {
input.query, input.query,
input.instrumentType, input.instrumentType,
).slice(FIRST_RESULT_OFFSET, input.exactTicker ? tickerAmbiguityLimit : catalogSearchLimit); ).slice(FIRST_RESULT_OFFSET, input.exactTicker ? tickerAmbiguityLimit : catalogSearchLimit);
const details = await Promise.all( const [details, prices] = await Promise.all([
instruments.map((item) => Promise.all(
input.instrumentType === 'share' instruments.map((item) =>
? this.tbank.getShare(token, item.uid) input.instrumentType === 'share'
: this.tbank.getBond(token, item.uid), ? this.tbank.getShare(token, item.uid)
: this.tbank.getBond(token, item.uid),
),
), ),
); instruments.length
const prices = instruments.length ? this.tbank.getLastPrices(token, instruments.map((item) => item.uid))
? await this.tbank.getLastPrices(token, instruments.map((item) => item.uid)) : [],
: []; ]);
const fetchedAt = new Date(); const fetchedAt = new Date();
const data = instruments.flatMap((item, index) => { const data = instruments.flatMap((item, index) => {
const detail = details.at(index); const detail = details.at(index);