Skip to content

Commit

Permalink
Merge pull request #2331 from openedx/pwnage101/ENT-9941-4
Browse files Browse the repository at this point in the history
fix: Do NOT skip validating intentions which have NO related catalog queries
  • Loading branch information
pwnage101 authored Feb 3, 2025
2 parents 8681006 + c771e68 commit 25e83be
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ Unreleased
----------
* nothing unreleased

[5.6.9]
--------
* fix: Do NOT skip validating intentions which have NO related catalog queries

[5.6.8]
--------
* chore: Upgrade Python requirements
Expand Down
2 changes: 1 addition & 1 deletion enterprise/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
Your project description goes here.
"""

__version__ = "5.6.8"
__version__ = "5.6.9"
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from django.core.management import BaseCommand, CommandError
from django.db.models import Max
from django.db.models.functions import Greatest
from django.db.models.functions import Coalesce, Greatest
from django.utils import timezone

from enterprise.content_metadata.api import get_and_cache_customer_content_metadata
Expand Down Expand Up @@ -98,7 +98,11 @@ def handle(self, *args, **options):
).annotate(
catalogs_modified_latest=Greatest(
Max("enterprise_customer__enterprise_customer_catalogs__modified"),
Max("enterprise_customer__enterprise_customer_catalogs__enterprise_catalog_query__modified"),
Coalesce(
Max("enterprise_customer__enterprise_customer_catalogs__enterprise_catalog_query__modified"),
# Arbitrarily default to 1 year ago. Greatest() in MySQL relies on all inputs being non-null.
timezone.now() - timedelta(days=360),
)
)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ def setUp(self):
@ddt.data(
# Totally happy case.
{},
# Happy case (customer evaluated despite not having any related catalog queries).
{
"catalog_query_exists": False,
},
# Happy-ish case (customer was skipped because catalog query was too new).
{
"catalog_query_modified": NOW - timedelta(minutes=29),
Expand Down Expand Up @@ -90,6 +94,7 @@ def test_validate_default_enrollment_intentions(
catalog_query_modified=NOW - timedelta(minutes=31),
catalog_modified=NOW - timedelta(minutes=31),
catalog_exists=True,
catalog_query_exists=True,
customer_content_metadata_api_success=True,
expected_logging="1/2 were evaluated (1/2 skipped)",
expected_command_error=False,
Expand Down Expand Up @@ -123,12 +128,15 @@ def test_validate_default_enrollment_intentions(
),
)
if catalog_exists:
self.catalog_query.modified = catalog_query_modified
# bulk_update() avoids signals.
EnterpriseCatalogQuery.objects.bulk_update(
[self.catalog_query],
["modified"],
)
if catalog_query_exists:
self.catalog_query.modified = catalog_query_modified
# bulk_update() avoids signals.
EnterpriseCatalogQuery.objects.bulk_update(
[self.catalog_query],
["modified"],
)
else:
self.catalog_query.delete()
self.catalog.modified = catalog_modified
EnterpriseCustomerCatalog.objects.bulk_update(
[self.catalog],
Expand Down

0 comments on commit 25e83be

Please sign in to comment.