perf: start bond search prices with details (WealthLedger/backend#71)
Backend verify / commits (pull_request) Successful in 37s
Backend verify / security (pull_request) Successful in 13s
Backend verify / verify (pull_request) Successful in 5m57s

This commit is contained in:
2026-10-14 13:23:15 +03:00
parent bbb5afff84
commit 392b8a8d09
@@ -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);