Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Merge branch 'master' of github.com:mirumee/saleor into SALEOR-2737-order-payment-status-performance
Tomasz Szymanskid1a6ac578c2e
diff --cc CHANGELOG.mdindex d6c6d4ea0f,fc52c8dbec..947015ed64--- a/CHANGELOG.md+++ b/CHANGELOG.md@@@ -42,7 -42,7 +42,8 @@@ All notable, unreleased changes to thi- Added validation for `DraftOrderCreate` with negative quantity line - #7085 by @d-wysocki- Remove html tags from product description_plaintext - #7094 by @d-wysocki- Performance upgrade on orders query with shipping and billing addresses - #7083 by @tomaszszymanski129+- Performance upgrade on orders query with payment status - #7125 by @tomaszszymanski129+ - Performance upgrade on orders query with events - #7120 by @tomaszszymanski129- Performance upgrade on orders query with `user` and `userEmail` fields - #7091 by @tomaszszymanski129- Fix dataloader for fetching checkout info - #7084 by @IKarbowiak- Update also draft order line total price after getting the unit price from plugin - #7080 by @IKarbowiakdiff --cc saleor/graphql/order/dataloaders.pyindex a0954b0c97,8f99d7636b..437f03dc64--- a/saleor/graphql/order/dataloaders.py+++ b/saleor/graphql/order/dataloaders.py@@@ -2,8 -2,7 +2,8 @@@ from collections import defaultdicfrom django.db.models import F- from ...order.models import Order, OrderLine+ from ...order.models import Order, OrderEvent, OrderLine+from ...payment.models import Paymentfrom ...warehouse.models import Allocationfrom ..core.dataloaders import DataLoader@@@ -52,17 -51,17 +52,28 @@@ class OrderLinesByOrderIdLoader(DataLoareturn [line_map.get(order_id, []) for order_id in keys]+class PaymentsByOrderIdLoader(DataLoader):+ context_key = "payments_by_order"++ def batch_load(self, keys):+ payments = Payment.objects.filter(order_id__in=keys).order_by("pk")+ payment_map = defaultdict(list)+ for payment in payments.iterator():+ payment_map[payment.order_id].append(payment)+ return [payment_map.get(order_id, []) for order_id in keys]+++ class OrderEventsByOrderIdLoader(DataLoader):+ context_key = "orderevents_by_order"++ def batch_load(self, keys):+ events = OrderEvent.objects.filter(order_id__in=keys).order_by("pk")+ events_map = defaultdict(list)+ for event in events.iterator():+ events_map[event.order_id].append(event)+ return [events_map.get(order_id, []) for order_id in keys]++class AllocationsByOrderLineIdLoader(DataLoader):context_key = "allocations_by_orderline_id"diff --cc saleor/graphql/order/types.pyindex 5a15ec95c0,d52a04c0d8..aea55ea6a0--- a/saleor/graphql/order/types.py+++ b/saleor/graphql/order/types.py@@@ -19,9 -19,7 +20,8 @@@ from ...graphql.warehouse.dataloaders ifrom ...order import OrderStatus, modelsfrom ...order.models import FulfillmentStatusfrom ...order.utils import get_order_country, get_valid_shipping_methods_for_order+from ...payment import ChargeStatusfrom ...product.product_images import get_product_image_thumbnail- from ...warehouse import models as warehouse_modelsfrom ..account.dataloaders import AddressByIdLoader, UserByUserIdLoaderfrom ..account.types import Userfrom ..account.utils import requestor_has_access@@@ -51,9 -49,9 +51,10 @@@ from ..warehouse.types import Allocatiofrom .dataloaders import (AllocationsByOrderLineIdLoader,OrderByIdLoader,+ OrderEventsByOrderIdLoader,OrderLineByIdLoader,OrderLinesByOrderIdLoader,+ PaymentsByOrderIdLoader,)from .enums import OrderEventsEmailsEnum, OrderEventsEnumfrom .utils import validate_draft_order