perf: start bond search prices with details (WealthLedger/backend#71) (#89)
This commit was merged in pull request #89.
This commit is contained in:
@@ -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([
|
||||||
|
Promise.all(
|
||||||
instruments.map((item) =>
|
instruments.map((item) =>
|
||||||
input.instrumentType === 'share'
|
input.instrumentType === 'share'
|
||||||
? this.tbank.getShare(token, item.uid)
|
? this.tbank.getShare(token, item.uid)
|
||||||
: this.tbank.getBond(token, item.uid),
|
: this.tbank.getBond(token, item.uid),
|
||||||
),
|
),
|
||||||
);
|
),
|
||||||
const prices = instruments.length
|
instruments.length
|
||||||
? await this.tbank.getLastPrices(token, instruments.map((item) => item.uid))
|
? 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);
|
||||||
|
|||||||
Reference in New Issue
Block a user