Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: allow both active and marketable runs in update_course_ai_translations #4441

Merged
merged 2 commits into from
Sep 12, 2024

Conversation

Ali-D-Akbar
Copy link
Contributor

PROD-4175
Adding an improvement to allow filtering both active and marketable runs.

@@ -51,10 +51,15 @@ def handle(self, *args, **options):

course_runs = CourseRun.objects.all()

if options['active']:
if options['active'] and options['marketable']:
course_runs = CourseRun.objects.filter(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[curious] Did you try course_runs.active().marketable()?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't that be an intersection of objects instead of Union? 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ouch, I did not realize we were doing a union here. Could we try course_runs.marketable().union(course_runs.active())?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like we can.

marketable_course_run.translation_languages,
[{'code': 'es', 'label': 'Spanish'}]
)
self.assertListEqual(non_active_course_run.translation_languages, [])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also have a non-marketable but active run with the same assertion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the active run is actually the non-marketable. Lemme rename that.

active_non_marketable_course_run.translation_languages,
[{'code': 'fr', 'label': 'French'}]
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a non-marketable non-active run and assert that the translation_languages are empty?

)
self.assertListEqual(
active_non_marketable_course_run.translation_languages,
[{'code': 'fr', 'label': 'French'}]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mock_get_translations returns Spanish, why is this French?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, the marketable course was also active somehow. Updated the test by adding end date to past.

@Ali-D-Akbar Ali-D-Akbar force-pushed the aakbar/PROD-4175 branch 2 times, most recently from c8a1904 to f6801e5 Compare September 12, 2024 12:44
@Ali-D-Akbar Ali-D-Akbar merged commit 34355f4 into master Sep 12, 2024
11 of 12 checks passed
@Ali-D-Akbar Ali-D-Akbar deleted the aakbar/PROD-4175 branch September 12, 2024 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants