feat(medusa): Performance improvements of Carts domain (#2648)
**What** I have created a new method on the cart service which is `addLineItems`, allowing a user to add one or multiple items in an optimized way. Also updated the `generate` method from the line item service which now also accept a object data or a collection of data which. Various places have been optimized and cache support has been added to the price selection strategy. The overall optimization allows to reach another 9000% improvement in the response time as a median (Creating a cart with 6 items): | | Min (ms) | Median (ms) | Max (ms) | Median Improvement (%) |---|:-:|---|---|---| | Before optimisation | 1200 | 9999 | 12698 | N/A | After optimisation | 63 | 252 | 500 | 39x | After re optimisation | 56 | 82 | 399 | 121x | After including addressed feedback | 65 | 202 | 495 | 49x FIXES CORE-722
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import {
|
||||
PriceList,
|
||||
CustomerGroup,
|
||||
MoneyAmount,
|
||||
PriceListType,
|
||||
PriceList,
|
||||
PriceListStatus,
|
||||
PriceListType,
|
||||
} from "@medusajs/medusa"
|
||||
import faker from "faker"
|
||||
import { Connection } from "typeorm"
|
||||
@@ -41,7 +42,7 @@ export const simplePriceListFactory = async (
|
||||
|
||||
const listId = data.id || `simple-price-list-${Math.random() * 1000}`
|
||||
|
||||
let customerGroups = []
|
||||
let customerGroups: CustomerGroup[] = []
|
||||
if (typeof data.customer_groups !== "undefined") {
|
||||
customerGroups = await Promise.all(
|
||||
data.customer_groups.map((group) =>
|
||||
|
||||
Reference in New Issue
Block a user