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
Showing only changes of commit 392b8a8d09 - Show all commits
@@ -304,16 +304,18 @@ export class CatalogDiscoveryService {
input.query,
input.instrumentType,
).slice(FIRST_RESULT_OFFSET, input.exactTicker ? tickerAmbiguityLimit : catalogSearchLimit);
const details = await Promise.all(
instruments.map((item) =>
input.instrumentType === 'share'
? this.tbank.getShare(token, item.uid)
: this.tbank.getBond(token, item.uid),
const [details, prices] = await Promise.all([
Promise.all(
instruments.map((item) =>
input.instrumentType === 'share'
? this.tbank.getShare(token, item.uid)
: this.tbank.getBond(token, item.uid),
),
),
);
const prices = instruments.length
? await this.tbank.getLastPrices(token, instruments.map((item) => item.uid))
: [];
instruments.length
? this.tbank.getLastPrices(token, instruments.map((item) => item.uid))
: [],
]);
const fetchedAt = new Date();
const data = instruments.flatMap((item, index) => {
const detail = details.at(index);