From 7bed9b4d1ff085204246a47440cb700c05f33229 Mon Sep 17 00:00:00 2001 From: Matthew Piatetsky Date: Thu, 14 Nov 2019 14:24:19 -0500 Subject: [PATCH] stop bucketing into discount experiment a week before cyber monday --- openedx/features/discounts/applicability.py | 5 ++++- openedx/features/discounts/utils.py | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/openedx/features/discounts/applicability.py b/openedx/features/discounts/applicability.py index d191979e01..b02bceb672 100644 --- a/openedx/features/discounts/applicability.py +++ b/openedx/features/discounts/applicability.py @@ -71,7 +71,10 @@ def get_discount_expiration_date(user, course): except ExperimentData.DoesNotExist: pass - if not time_limit_start: + now = datetime.now(tz=pytz.UTC) + stop_bucketing_into_discount_experiment = datetime(2019, 11, 22, 0, 0, 0, 0, pytz.UTC) + + if not time_limit_start and not now > stop_bucketing_into_discount_experiment: enrollment = course_enrollment.first() try: # Content availability date is equivalent to max(enrollment date, course start date) diff --git a/openedx/features/discounts/utils.py b/openedx/features/discounts/utils.py index 8f5576ea5a..bac15e37cd 100644 --- a/openedx/features/discounts/utils.py +++ b/openedx/features/discounts/utils.py @@ -104,13 +104,17 @@ def get_first_purchase_offer_banner_fragment(user, course): discount percentage and a link to upgrade. """ if user and not user.is_anonymous and course: - now = datetime.now(tz=pytz.UTC).strftime(u"%Y-%m-%d %H:%M:%S%z") + now = datetime.now(tz=pytz.UTC) + stop_bucketing_into_discount_experiment = datetime(2019, 11, 22, 0, 0, 0, 0, pytz.UTC) saw_banner = ExperimentData.objects.filter( user=user, experiment_id=REV1008_EXPERIMENT_ID, key=str(course) ) - if not saw_banner: + if not saw_banner and not now > stop_bucketing_into_discount_experiment: ExperimentData.objects.create( - user=user, experiment_id=REV1008_EXPERIMENT_ID, key=str(course), value=now + user=user, + experiment_id=REV1008_EXPERIMENT_ID, + key=str(course), + value=now.strftime(u"%Y-%m-%d %H:%M:%S%z") ) discount_expiration_date = get_discount_expiration_date(user, course) if (discount_expiration_date and