Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Benchmarks for orders query - user and userEmail fields
Tomasz Szymanski03ddac84c9fa
diff --git a/saleor/graphql/order/tests/benchmark/fixtures.py b/saleor/graphql/order/tests/benchmark/fixtures.pyindex f7f921a6b4..33224ba56b 100644--- a/saleor/graphql/order/tests/benchmark/fixtures.py+++ b/saleor/graphql/order/tests/benchmark/fixtures.py@@ -3,18 +3,35 @@ import uuidimport pytestfrom prices import Money, TaxedMoney+from .....account.models import Userfrom .....order.models import Order@pytest.fixture-def orders_for_benchmarks(channel_USD, address, customer_user):+def users_for_benchmarks(address):+ users = [+ User(+ email=f"john.doe.{i}@exmaple.com",+ is_active=True,+ default_billing_address=address.get_copy(),+ default_shipping_address=address.get_copy(),+ first_name="John",+ last_name="Doe",+ )+ for i in range(10)+ ]+ return User.objects.bulk_create(users)+++def orders_for_benchmarks(channel_USD, address, users_for_benchmarks):orders = [Order(token=str(uuid.uuid4()),channel=channel_USD,billing_address=address.get_copy(),shipping_address=address.get_copy(),- user=customer_user,+ user=users_for_benchmarks[i],total=TaxedMoney(net=Money(i, "USD"), gross=Money(i, "USD")),)for i in range(10)diff --git a/saleor/graphql/order/tests/benchmark/test_order.py b/saleor/graphql/order/tests/benchmark/test_order.pyindex f1ad4019a0..cb19853a6e 100644--- a/saleor/graphql/order/tests/benchmark/test_order.py+++ b/saleor/graphql/order/tests/benchmark/test_order.py@@ -8,14 +8,14 @@ from ....checkout.tests.benchmark.test_checkout_mutations import (from ....tests.utils import get_graphql_contentFRAGMENT_DISCOUNTS = """- fragment OrderDiscounts on OrderDiscount {- id- type- valueType- value- name- translatedName- }+ fragment OrderDiscounts on OrderDiscount {+ id+ type+ valueType+ value+ name+ translatedName+ }"""FRAGMENT_ORDER_DETAILS = (@@ -23,41 +23,41 @@ FRAGMENT_ORDER_DETAILS = (+ FRAGMENT_PRODUCT_VARIANT+ FRAGMENT_DISCOUNTS+ """- fragment OrderDetail on Order {- userEmail- paymentStatus- paymentStatusDisplay- status- statusDisplay- id- number- shippingAddress {- ...Address- }- discounts {- ...OrderDiscounts- }- lines {- productName- quantity- variant {- ...ProductVariant- }- unitPrice {- currency- ...Price- }- }- subtotal {- ...Price- }- total {- ...Price+ fragment OrderDetail on Order {+ userEmail+ paymentStatus+ paymentStatusDisplay+ status+ statusDisplay+ id+ number+ shippingAddress {+ ...Address+ }+ discounts {+ ...OrderDiscounts+ }+ lines {+ productName+ quantity+ variant {+ ...ProductVariant}- shippingPrice {+ unitPrice {+ currency...Price}}+ subtotal {+ ...Price+ }+ total {+ ...Price+ }+ shippingPrice {+ ...Price+ }+ }""")@@ -70,11 +70,11 @@ def test_user_order_details(query = (FRAGMENT_ORDER_DETAILS+ """- query OrderByToken($token: UUID!) {- orderByToken(token: $token) {- ...OrderDetail- }+ query OrderByToken($token: UUID!) {+ orderByToken(token: $token) {+ ...OrderDetail}+ }""")variables = {@@ -86,45 +86,44 @@ def test_user_order_details(FRAGMENT_STAFF_ORDER_DETAILS = (FRAGMENT_ORDER_DETAILS+ """- fragment OrderStaffDetail on Order {- ...OrderDetail- events {- id- date- type- user {+ fragment OrderStaffDetail on Order {+ ...OrderDetail+ events {+ id+ date+ type+ user {+ }+ message- }- message- emailType- amount- paymentId- paymentGateway- quantity- composedId- orderNumber- invoiceNumber- oversoldItems- lines {- itemName- }- fulfilledItems {- orderLine {+ emailType+ amount+ paymentId+ paymentGateway+ quantity+ composedId+ orderNumber+ invoiceNumber+ oversoldItems+ lines {+ itemName+ }+ fulfilledItems {+ orderLine {+ id+ }+ }+ warehouse {+ id+ }+ transactionReference+ shippingCostsIncluded+ relatedOrder {id}- }- warehouse {- id- }- transactionReference- shippingCostsIncluded- relatedOrder {- id}}- }-""")@@ -140,12 +139,12 @@ def test_staff_order_details(query = (FRAGMENT_STAFF_ORDER_DETAILS+ """- query Order($id: ID!) {- order(id: $id) {- ...OrderStaffDetail- }- }- """+ query Order($id: ID!) {+ order(id: $id) {+ ...OrderStaffDetail+ }+ }+ """)variables = {"id": graphene.Node.to_global_id("Order", order_with_lines_and_events.id),@@ -166,6 +165,10 @@ MULTIPLE_ORDER_ADDRESS_DETAILS_QUERY = """billingAddress {id}+ user {+ id+ }+ userEmail}}}@@ -175,13 +178,16 @@ MULTIPLE_ORDER_ADDRESS_DETAILS_QUERY = """@pytest.mark.django_db@pytest.mark.count_queries(autouse=False)-def test_staff_multiple_orders_address_resolving(+def test_staff_multiple_orders(staff_api_client,permission_manage_orders,+ permission_manage_users,orders_for_benchmarks,count_queries,):- staff_api_client.user.user_permissions.add(permission_manage_orders)+ staff_api_client.user.user_permissions.set(+ [permission_manage_orders, permission_manage_users]+ )content = get_graphql_content(staff_api_client.post_graphql(MULTIPLE_ORDER_ADDRESS_DETAILS_QUERY))