Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Use dataloader for discounts instead of lazy object (#10512)
Dominik Kozaczkoa579eb534e06
diff --git a/saleor/core/middleware.py b/saleor/core/middleware.pyindex be90559985..c840816ea6 100644--- a/saleor/core/middleware.py+++ b/saleor/core/middleware.py@@ -10,7 +10,6 @@ from django.utils import timezonefrom django.utils.functional import SimpleLazyObjectfrom django.utils.translation import get_language-from ..discount.utils import fetch_discountsfrom ..graphql.utils import get_user_or_app_from_contextfrom ..plugins.manager import PluginsManager, get_plugins_managerfrom . import analytics@@ -55,18 +54,6 @@ def request_time(get_response):return _stamp_request-def discounts(get_response):- """Assign active discounts to `request.discounts`."""-- def _discounts_middleware(request):- request.discounts = SimpleLazyObject(- lambda: fetch_discounts(request.request_time)- )- return get_response(request)-- return _discounts_middleware--def site(get_response):"""Clear the Sites cache and assign the current site to `request.site`.diff --git a/saleor/graphql/checkout/dataloaders.py b/saleor/graphql/checkout/dataloaders.pyindex 794a188ed2..2bcf8a2e46 100644--- a/saleor/graphql/checkout/dataloaders.py+++ b/saleor/graphql/checkout/dataloaders.py@@ -15,7 +15,11 @@ from ...discount import VoucherTypefrom ...payment.models import TransactionItemfrom ..account.dataloaders import AddressByIdLoader, UserByUserIdLoaderfrom ..core.dataloaders import DataLoader-from ..discount.dataloaders import VoucherByCodeLoader, VoucherInfoByVoucherCodeLoader+from ..discount.dataloaders import (+ VoucherByCodeLoader,+ VoucherInfoByVoucherCodeLoader,+ load_discounts,+)from ..product.dataloaders import (CollectionsByVariantIdLoader,ProductByVariantIdLoader,@@ -103,11 +107,12 @@ class CheckoutLinesInfoByCheckoutTokenLoader(DataLoader):voucher.type == VoucherType.SPECIFIC_PRODUCTor voucher.apply_once_per_order):+ discounts = load_discounts(self.context)apply_voucher_to_checkout_line(voucher_info=voucher_info,checkout=checkout,lines_info=lines_info_map[checkout.pk],- discounts=self.context.discounts,+ discounts=discounts,)return [lines_info_map[key] for key in keys]@@ -298,7 +303,7 @@ class CheckoutInfoByCheckoutTokenLoader(DataLoader):)manager = self.context.plugins- discounts = self.context.discounts+ discounts = load_discounts(self.context)shipping_method_listings = [listingfor channel_listings in listings_for_channelsdiff --git a/saleor/graphql/checkout/mutations/checkout_add_promo_code.py b/saleor/graphql/checkout/mutations/checkout_add_promo_code.pyindex b2e9af88c7..bcbc749028 100644--- a/saleor/graphql/checkout/mutations/checkout_add_promo_code.py+++ b/saleor/graphql/checkout/mutations/checkout_add_promo_code.py@@ -13,6 +13,7 @@ from ...core.descriptions import ADDED_IN_34, DEPRECATED_IN_3X_INPUTfrom ...core.mutations import BaseMutationfrom ...core.scalars import UUIDfrom ...core.types import CheckoutError+from ...discount.dataloaders import load_discountsfrom ..types import Checkoutfrom .utils import get_checkout, update_checkout_shipping_method_if_invalid@@ -62,7 +63,7 @@ class CheckoutAddPromoCode(BaseMutation):validate_checkout_email(checkout)manager = info.context.plugins- discounts = info.context.discounts+ discounts = load_discounts(info.context)lines, unavailable_variant_pks = fetch_checkout_lines(checkout)if unavailable_variant_pks:diff --git a/saleor/graphql/checkout/mutations/checkout_billing_address_update.py b/saleor/graphql/checkout/mutations/checkout_billing_address_update.pyindex 8a07ec0ee6..8c87c4188f 100644--- a/saleor/graphql/checkout/mutations/checkout_billing_address_update.py+++ b/saleor/graphql/checkout/mutations/checkout_billing_address_update.py@@ -17,6 +17,7 @@ from ...core.descriptions import ()from ...core.scalars import UUIDfrom ...core.types import CheckoutError+from ...discount.dataloaders import load_discountsfrom ..types import Checkoutfrom .checkout_create import CheckoutAddressValidationRulesfrom .checkout_shipping_address_update import CheckoutShippingAddressUpdate@@ -96,14 +97,15 @@ class CheckoutBillingAddressUpdate(CheckoutShippingAddressUpdate):checkout, billing_address)lines, _ = fetch_checkout_lines(checkout)+ discounts = load_discounts(info.context)checkout_info = fetch_checkout_info(- checkout, lines, info.context.discounts, info.context.plugins+ checkout, lines, discounts, info.context.plugins)invalidate_prices_updated_fields = invalidate_checkout_prices(checkout_info,lines,info.context.plugins,- info.context.discounts,+ discounts,recalculate_discount=False,save=False,)diff --git a/saleor/graphql/checkout/mutations/checkout_complete.py b/saleor/graphql/checkout/mutations/checkout_complete.pyindex bbb9a31b3d..65db41c873 100644--- a/saleor/graphql/checkout/mutations/checkout_complete.py+++ b/saleor/graphql/checkout/mutations/checkout_complete.py@@ -26,6 +26,7 @@ from ...core.mutations import BaseMutationfrom ...core.scalars import UUIDfrom ...core.types import CheckoutErrorfrom ...core.validators import validate_one_of_args_is_in_mutation+from ...discount.dataloaders import load_discountsfrom ...order.types import Orderfrom ...utils import get_user_or_app_from_contextfrom ..types import Checkout@@ -232,9 +233,8 @@ class CheckoutComplete(BaseMutation, I18nMixin):)})- checkout_info = fetch_checkout_info(- checkout, lines, info.context.discounts, manager- )+ discounts = load_discounts(info.context)+ checkout_info = fetch_checkout_info(checkout, lines, discounts, manager)cls.validate_checkout_addresses(lines, checkout_info.shipping_address, checkout_info.billing_address@@ -254,7 +254,7 @@ class CheckoutComplete(BaseMutation, I18nMixin):lines=lines,payment_data=data.get("payment_data", {}),store_source=store_source,- discounts=info.context.discounts,+ discounts=discounts,user=customer,app=load_app(info.context),site_settings=info.context.site.settings,diff --git a/saleor/graphql/checkout/mutations/checkout_delivery_method_update.py b/saleor/graphql/checkout/mutations/checkout_delivery_method_update.pyindex 327f12dba4..5aed78efd9 100644--- a/saleor/graphql/checkout/mutations/checkout_delivery_method_update.py+++ b/saleor/graphql/checkout/mutations/checkout_delivery_method_update.py@@ -32,6 +32,7 @@ from ...core.mutations import BaseMutationfrom ...core.scalars import UUIDfrom ...core.types import CheckoutErrorfrom ...core.utils import from_global_id_or_error+from ...discount.dataloaders import load_discountsfrom ...shipping.types import ShippingMethodfrom ...warehouse.types import Warehousefrom ..types import Checkout@@ -88,11 +89,12 @@ class CheckoutDeliveryMethodUpdate(BaseMutation):checkout_info, lines, shipping_method=delivery_method, collection_point=None)+ discounts = load_discounts(info.context)cls._update_delivery_method(manager,checkout_info,lines,- info.context.discounts,+ discounts,shipping_method=shipping_method,external_shipping_method=None,collection_point=None,@@ -123,11 +125,12 @@ class CheckoutDeliveryMethodUpdate(BaseMutation):checkout_info, lines, shipping_method=delivery_method, collection_point=None)+ discounts = load_discounts(info.context)cls._update_delivery_method(manager,checkout_info,lines,- info.context.discounts,+ discounts,shipping_method=None,external_shipping_method=delivery_method,collection_point=None,@@ -151,11 +154,12 @@ class CheckoutDeliveryMethodUpdate(BaseMutation):shipping_method=None,collection_point=collection_point,)+ discounts = load_discounts(info.context)cls._update_delivery_method(manager,checkout_info,lines,- info.context.discounts,+ discounts,shipping_method=None,external_shipping_method=None,collection_point=collection_point,@@ -290,9 +294,8 @@ class CheckoutDeliveryMethodUpdate(BaseMutation):)type_name = cls._resolve_delivery_method_type(delivery_method_id)- checkout_info = fetch_checkout_info(- checkout, lines, info.context.discounts, manager- )+ discounts = load_discounts(info.context)+ checkout_info = fetch_checkout_info(checkout, lines, discounts, manager)if type_name == "Warehouse":return cls.perform_on_collection_point(info, delivery_method_id, checkout_info, lines, checkout, managerdiff --git a/saleor/graphql/checkout/mutations/checkout_line_delete.py b/saleor/graphql/checkout/mutations/checkout_line_delete.pyindex 33ad947b3c..959a3313bc 100644--- a/saleor/graphql/checkout/mutations/checkout_line_delete.py+++ b/saleor/graphql/checkout/mutations/checkout_line_delete.py@@ -7,6 +7,7 @@ from ...core.descriptions import ADDED_IN_34, DEPRECATED_IN_3X_INPUTfrom ...core.mutations import BaseMutationfrom ...core.scalars import UUIDfrom ...core.types import CheckoutError+from ...discount.dataloaders import load_discountsfrom ..types import Checkout, CheckoutLinefrom .utils import get_checkout, update_checkout_shipping_method_if_invalid@@ -58,13 +59,10 @@ class CheckoutLineDelete(BaseMutation):manager = info.context.pluginslines, _ = fetch_checkout_lines(checkout)- checkout_info = fetch_checkout_info(- checkout, lines, info.context.discounts, manager- )+ discounts = load_discounts(info.context)+ checkout_info = fetch_checkout_info(checkout, lines, discounts, manager)update_checkout_shipping_method_if_invalid(checkout_info, lines)- invalidate_checkout_prices(- checkout_info, lines, manager, info.context.discounts, save=True- )+ invalidate_checkout_prices(checkout_info, lines, manager, discounts, save=True)manager.checkout_updated(checkout)return CheckoutLineDelete(checkout=checkout)diff --git a/saleor/graphql/checkout/mutations/checkout_lines_add.py b/saleor/graphql/checkout/mutations/checkout_lines_add.pyindex 2c11abd4c4..e89fe8593e 100644--- a/saleor/graphql/checkout/mutations/checkout_lines_add.py+++ b/saleor/graphql/checkout/mutations/checkout_lines_add.py@@ -16,6 +16,7 @@ from ...core.mutations import BaseMutationfrom ...core.scalars import UUIDfrom ...core.types import CheckoutError, NonNullListfrom ...core.validators import validate_variants_available_in_channel+from ...discount.dataloaders import load_discountsfrom ...product.types import ProductVariantfrom ..types import Checkoutfrom .checkout_create import CheckoutLineInput@@ -177,7 +178,7 @@ class CheckoutLinesAdd(BaseMutation):error_class=CheckoutErrorCode,)- discounts = info.context.discounts+ discounts = load_discounts(info.context)manager = info.context.pluginsvariants = cls._get_variants_from_lines_input(lines)diff --git a/saleor/graphql/checkout/mutations/checkout_lines_delete.py b/saleor/graphql/checkout/mutations/checkout_lines_delete.pyindex a9cd55d1e9..8158b57fbe 100644--- a/saleor/graphql/checkout/mutations/checkout_lines_delete.py+++ b/saleor/graphql/checkout/mutations/checkout_lines_delete.py@@ -8,6 +8,7 @@ from ...core.descriptions import ADDED_IN_34, DEPRECATED_IN_3X_INPUTfrom ...core.mutations import BaseMutationfrom ...core.scalars import UUIDfrom ...core.types import CheckoutError, NonNullList+from ...discount.dataloaders import load_discountsfrom ...utils import resolve_global_ids_to_primary_keysfrom ..types import Checkoutfrom .utils import get_checkout, update_checkout_shipping_method_if_invalid@@ -77,13 +78,10 @@ class CheckoutLinesDelete(BaseMutation):lines, _ = fetch_checkout_lines(checkout)manager = info.context.plugins- checkout_info = fetch_checkout_info(- checkout, lines, info.context.discounts, manager- )+ discounts = load_discounts(info.context)+ checkout_info = fetch_checkout_info(checkout, lines, discounts, manager)update_checkout_shipping_method_if_invalid(checkout_info, lines)- invalidate_checkout_prices(- checkout_info, lines, manager, info.context.discounts, save=True- )+ invalidate_checkout_prices(checkout_info, lines, manager, discounts, save=True)manager.checkout_updated(checkout)return CheckoutLinesDelete(checkout=checkout)diff --git a/saleor/graphql/checkout/mutations/checkout_remove_promo_code.py b/saleor/graphql/checkout/mutations/checkout_remove_promo_code.pyindex 7c28429a24..6781dea770 100644--- a/saleor/graphql/checkout/mutations/checkout_remove_promo_code.py+++ b/saleor/graphql/checkout/mutations/checkout_remove_promo_code.py@@ -18,6 +18,7 @@ from ...core.scalars import UUIDfrom ...core.types import CheckoutErrorfrom ...core.utils import from_global_id_or_errorfrom ...core.validators import validate_one_of_args_is_in_mutation+from ...discount.dataloaders import load_discountsfrom ...discount.types import Voucherfrom ...giftcard.types import GiftCardfrom ..types import Checkout@@ -84,9 +85,8 @@ class CheckoutRemovePromoCode(BaseMutation):)manager = info.context.plugins- checkout_info = fetch_checkout_info(- checkout, [], info.context.discounts, manager- )+ discounts = load_discounts(info.context)+ checkout_info = fetch_checkout_info(checkout, [], discounts, manager)removed = Falseif promo_code:@@ -102,7 +102,7 @@ class CheckoutRemovePromoCode(BaseMutation):checkout_info,lines,manager,- info.context.discounts,+ discounts,recalculate_discount=False,save=True,)diff --git a/saleor/graphql/checkout/mutations/checkout_shipping_address_update.py b/saleor/graphql/checkout/mutations/checkout_shipping_address_update.pyindex addbdfeac8..4a91c15cb9 100644--- a/saleor/graphql/checkout/mutations/checkout_shipping_address_update.py+++ b/saleor/graphql/checkout/mutations/checkout_shipping_address_update.py@@ -29,6 +29,7 @@ from ...core.descriptions import (from ...core.mutations import BaseMutationfrom ...core.scalars import UUIDfrom ...core.types import CheckoutError+from ...discount.dataloaders import load_discountsfrom ..types import Checkoutfrom .checkout_create import CheckoutAddressValidationRulesfrom .utils import (@@ -154,7 +155,7 @@ class CheckoutShippingAddressUpdate(BaseMutation, I18nMixin):),)- discounts = info.context.discounts+ discounts = load_discounts(info.context)manager = info.context.pluginsshipping_channel_listings = checkout.channel.shipping_method_listings.all()checkout_info = fetch_checkout_info(diff --git a/saleor/graphql/checkout/mutations/checkout_shipping_method_update.py b/saleor/graphql/checkout/mutations/checkout_shipping_method_update.pyindex 5ff1a63129..9c49fbc264 100644--- a/saleor/graphql/checkout/mutations/checkout_shipping_method_update.py+++ b/saleor/graphql/checkout/mutations/checkout_shipping_method_update.py@@ -20,6 +20,7 @@ from ...core.mutations import BaseMutationfrom ...core.scalars import UUIDfrom ...core.types import CheckoutErrorfrom ...core.utils import from_global_id_or_error+from ...discount.dataloaders import load_discountsfrom ...shipping.types import ShippingMethodfrom ..types import Checkoutfrom .utils import ERROR_DOES_NOT_SHIP, clean_delivery_method, get_checkout@@ -101,10 +102,8 @@ class CheckoutShippingMethodUpdate(BaseMutation):)})-- checkout_info = fetch_checkout_info(- checkout, lines, info.context.discounts, manager- )+ discounts = load_discounts(info.context)+ checkout_info = fetch_checkout_info(checkout, lines, discounts, manager)if not is_shipping_required(lines):raise ValidationError({@@ -174,8 +173,9 @@ class CheckoutShippingMethodUpdate(BaseMutation):delete_external_shipping_id(checkout=checkout)checkout.shipping_method = shipping_method+ discounts = load_discounts(info.context)invalidate_prices_updated_fields = invalidate_checkout_prices(- checkout_info, lines, manager, info.context.discounts, save=False+ checkout_info, lines, manager, discounts, save=False)checkout.save(update_fields=[@@ -204,8 +204,9 @@ class CheckoutShippingMethodUpdate(BaseMutation):set_external_shipping_id(checkout=checkout, app_shipping_id=delivery_method.id)checkout.shipping_method = None+ discounts = load_discounts(info.context)invalidate_prices_updated_fields = invalidate_checkout_prices(- checkout_info, lines, manager, info.context.discounts, save=False+ checkout_info, lines, manager, discounts, save=False)checkout.save(update_fields=[diff --git a/saleor/graphql/checkout/mutations/order_create_from_checkout.py b/saleor/graphql/checkout/mutations/order_create_from_checkout.pyindex da66bf0861..0076649ef2 100644--- a/saleor/graphql/checkout/mutations/order_create_from_checkout.py+++ b/saleor/graphql/checkout/mutations/order_create_from_checkout.py@@ -12,6 +12,7 @@ from ...app.dataloaders import load_appfrom ...core.descriptions import ADDED_IN_32, PREVIEW_FEATUREfrom ...core.mutations import BaseMutationfrom ...core.types import Error+from ...discount.dataloaders import load_discountsfrom ...order.types import Orderfrom ..enums import OrderCreateFromCheckoutErrorCodefrom ..types import Checkout@@ -83,7 +84,7 @@ class OrderCreateFromCheckout(BaseMutation):)tracking_code = analytics.get_client_id(info.context)- discounts = info.context.discounts+ discounts = load_discounts(info.context)manager = info.context.pluginscheckout_lines, unavailable_variant_pks = fetch_checkout_lines(checkout)checkout_info = fetch_checkout_info(@@ -102,7 +103,7 @@ class OrderCreateFromCheckout(BaseMutation):order = create_order_from_checkout(checkout_info=checkout_info,checkout_lines=checkout_lines,- discounts=info.context.discounts,+ discounts=discounts,manager=info.context.plugins,user=info.context.user,app=app,diff --git a/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py b/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.pyindex e8a7ff7da6..9dbd986e0e 100644--- a/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py+++ b/saleor/graphql/checkout/tests/benchmark/test_checkout_mutations.py@@ -658,7 +658,7 @@ def test_update_checkout_lines_with_reservations(reservation_length=5,)- with django_assert_num_queries(54):+ with django_assert_num_queries(53):variant_id = graphene.Node.to_global_id("ProductVariant", variants[0].pk)variables = {"id": to_global_id_or_none(checkout),@@ -672,7 +672,7 @@ def test_update_checkout_lines_with_reservations(assert not data["errors"]# Updating multiple lines in checkout has same query count as updating one- with django_assert_num_queries(54):+ with django_assert_num_queries(53):variables = {"id": to_global_id_or_none(checkout),"lines": [],@@ -915,7 +915,7 @@ def test_add_checkout_lines_with_reservations(new_lines.append({"quantity": 2, "variantId": variant_id})# Adding multiple lines to checkout has same query count as adding one- with django_assert_num_queries(53):+ with django_assert_num_queries(52):variables = {"id": Node.to_global_id("Checkout", checkout.pk),"lines": [new_lines[0]],@@ -928,7 +928,7 @@ def test_add_checkout_lines_with_reservations(checkout.lines.exclude(id=line.id).delete()- with django_assert_num_queries(53):+ with django_assert_num_queries(52):variables = {"id": Node.to_global_id("Checkout", checkout.pk),"lines": new_lines,diff --git a/saleor/graphql/discount/dataloaders.py b/saleor/graphql/discount/dataloaders.pyindex 98c7b01b92..d6cd6f0d8d 100644--- a/saleor/graphql/discount/dataloaders.py+++ b/saleor/graphql/discount/dataloaders.py@@ -227,3 +227,7 @@ class OrderDiscountsByOrderIDLoader(DataLoader):for discount in discounts:discount_map[discount.order_id].append(discount)return [discount_map.get(order_id, []) for order_id in keys]+++def load_discounts(request):+ return DiscountsByDateTimeLoader(request).load(request.request_time).get()diff --git a/saleor/graphql/order/mutations/order_lines_create.py b/saleor/graphql/order/mutations/order_lines_create.pyindex 2183406ae1..75428dc2c0 100644--- a/saleor/graphql/order/mutations/order_lines_create.py+++ b/saleor/graphql/order/mutations/order_lines_create.py@@ -20,6 +20,7 @@ from ....order.utils import (from ...app.dataloaders import load_appfrom ...core.mutations import BaseMutationfrom ...core.types import NonNullList, OrderError+from ...discount.dataloaders import load_discountsfrom ...product.types import ProductVariantfrom ..types import Order, OrderLinefrom ..utils import (@@ -153,7 +154,7 @@ class OrderLinesCreate(EditableOrderValidationMixin, BaseMutation):variants = [line.variant for line in lines_to_add]cls.validate_variants(order, variants)app = load_app(info.context)-+ discounts = load_discounts(info.context)added_lines = cls.add_lines_to_order(order,lines_to_add,@@ -161,7 +162,7 @@ class OrderLinesCreate(EditableOrderValidationMixin, BaseMutation):app,info.context.plugins,info.context.site.settings,- info.context.discounts,+ discounts,)# Create the products added eventdiff --git a/saleor/graphql/payment/mutations.py b/saleor/graphql/payment/mutations.pyindex 1a5a12a790..b7052b9384 100644--- a/saleor/graphql/payment/mutations.py+++ b/saleor/graphql/payment/mutations.py@@ -48,6 +48,7 @@ from ..core.fields import JSONStringfrom ..core.mutations import BaseMutationfrom ..core.scalars import UUID, PositiveDecimalfrom ..core.types import common as common_types+from ..discount.dataloaders import load_discountsfrom ..meta.mutations import MetadataInputfrom ..utils import get_user_or_app_from_contextfrom .enums import StorePaymentMethodEnum, TransactionActionEnum, TransactionStatusEnum@@ -272,9 +273,8 @@ class CheckoutPaymentCreate(BaseMutation, I18nMixin):)})- checkout_info = fetch_checkout_info(- checkout, lines, info.context.discounts, manager- )+ discounts = load_discounts(info.context)+ checkout_info = fetch_checkout_info(checkout, lines, discounts, manager)cls.validate_token(manager, gateway, data, channel_slug=checkout_info.channel.slug@@ -288,7 +288,7 @@ class CheckoutPaymentCreate(BaseMutation, I18nMixin):checkout_info=checkout_info,lines=lines,address=address,- discounts=info.context.discounts,+ discounts=discounts,)amount = data.get("amount", checkout_total.gross.amount)clean_checkout_shipping(checkout_info, lines, PaymentErrorCode)diff --git a/saleor/graphql/webhook/resolvers.py b/saleor/graphql/webhook/resolvers.pyindex c5b50b6c5c..6e17715e24 100644--- a/saleor/graphql/webhook/resolvers.py+++ b/saleor/graphql/webhook/resolvers.py@@ -11,6 +11,7 @@ from ...webhook.deprecated_event_types import WebhookEventTypefrom ...webhook.event_types import WebhookEventAsyncType, WebhookEventSyncTypefrom ..app.dataloaders import load_appfrom ..core.utils import from_global_id_or_error+from ..discount.dataloaders import load_discountsfrom .types import Webhook, WebhookEvent@@ -48,7 +49,7 @@ def resolve_sample_payload(info, event_name):def resolve_shipping_methods_for_checkout(info, checkout):manager = info.context.plugins- discounts = info.context.discounts+ discounts = load_discounts(info.context)lines, _ = fetch_checkout_lines(checkout)shipping_channel_listings = checkout.channel.shipping_method_listings.all()checkout_info = fetch_checkout_info(@@ -63,7 +64,7 @@ def resolve_shipping_methods_for_checkout(info, checkout):checkout_info,checkout.shipping_address,lines,- info.context.discounts,+ discounts,shipping_channel_listings,manager,)diff --git a/saleor/graphql/webhook/subscription_payload.py b/saleor/graphql/webhook/subscription_payload.pyindex a81a5ad49f..10d8971fb7 100644--- a/saleor/graphql/webhook/subscription_payload.py+++ b/saleor/graphql/webhook/subscription_payload.py@@ -14,7 +14,6 @@ from promise import Promisefrom ...app.models import Appfrom ...core.exceptions import PermissionDenied-from ...discount.utils import fetch_discountsfrom ...plugins.manager import PluginsManagerfrom ...settings import get_hostfrom ...webhook.error_codes import WebhookErrorCode@@ -99,9 +98,6 @@ def initialize_request(requestor=None, sync_event=False) -> HttpRequest:request.requestor = requestor # type: ignorerequest.request_time = request_time # type: ignorerequest.site = SimpleLazyObject(lambda: Site.objects.get_current()) # type: ignore- request.discounts = SimpleLazyObject( # type: ignore- lambda: fetch_discounts(request_time)- )request.plugins = SimpleLazyObject(lambda: _get_plugins(requestor)) # type: ignorereturn requestdiff --git a/saleor/settings.py b/saleor/settings.pyindex fe02d73e07..f4a4f6d323 100644--- a/saleor/settings.py+++ b/saleor/settings.py@@ -201,7 +201,6 @@ MIDDLEWARE = ["django.middleware.security.SecurityMiddleware","django.middleware.common.CommonMiddleware","saleor.core.middleware.request_time",- "saleor.core.middleware.discounts","saleor.core.middleware.google_analytics","saleor.core.middleware.site","saleor.core.middleware.plugins",