Skip to content

Commit

Permalink
fix: issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Anas12091101 committed Jan 31, 2025
1 parent 951559b commit b281ab5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions courses/sync_external_courses/external_course_sync_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -844,13 +844,15 @@ def deactivate_removed_course_runs(external_course_run_codes, platform_name):
start_date__gt=now_in_utc(),
live=True,
).exclude(external_course_run_id__in=external_course_run_codes)
course_runs.update(live=False)

Product.objects.filter(object_id__in=Subquery(course_runs.values("id"))).update(
is_active=False
)

deactivated_runs_count = course_runs.count()
deactivated_runs_list = course_runs.values_list("external_course_run_id", flat=True)
course_runs.update(live=False)
log.info(
f"Deactivated {course_runs.count()} course runs for platform {platform_name}."
f"Deactivated {deactivated_runs_count} course runs for platform {platform_name}."
)
return set(course_runs.values_list("external_course_run_id", flat=True))
return set(deactivated_runs_list)
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ def test_create_or_update_product_and_product_version( # noqa: PLR0913
assert version_created == expected_product_version_created
assert course_run.products.first().latest_version.description
assert course_run.products.first().latest_version.text_id
assert course_run.products.first().is_active == True
assert course_run.products.first().is_active


@pytest.mark.django_db
Expand Down

0 comments on commit b281ab5

Please sign in to comment.