Skip to content

Commit

Permalink
using Learning resources as content type when there are multiple uniq…
Browse files Browse the repository at this point in the history
…ue types
  • Loading branch information
shanbady committed Dec 9, 2024
1 parent 67082a3 commit 5425fec
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
6 changes: 5 additions & 1 deletion learning_resources_search/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -923,7 +923,11 @@ def _generate_subscription_digest_subject(
"""
prefix = "" if shortform else "MIT Learn: "
resource_type = unique_resource_types.pop()
if len(unique_resource_types) == 1:
resource_type = unique_resource_types.pop()
else:
resource_type = "Learning Resource"

if sample_course["source_channel_type"] == "saved_search":
if shortform:
return f"New {resource_type}{pluralize(total_count)} from MIT Learn"
Expand Down
30 changes: 30 additions & 0 deletions learning_resources_search/tasks_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,36 @@ def test_subscription_digest_subject():
assert subject_line == "New courses from management"


def test_subscription_digest_subject_multiple_types():
"""
Test that when there are multiple unique resource types
we use Leaning Resource in the header
"""
resource_types = {"program"}
sample_course = {"source_channel_type": "topic", "resource_title": "robotics"}

subject_line = _generate_subscription_digest_subject(
sample_course,
"electronics",
resource_types,
total_count=1,
shortform=False,
)
assert subject_line == "MIT Learn: New program in electronics: robotics"

sample_course = {"source_channel_type": "podcast", "resource_title": "robotics"}
resource_types = {"program", "video", "podcast"}

subject_line = _generate_subscription_digest_subject(
sample_course,
"xpro",
resource_types,
total_count=9,
shortform=False,
)
assert subject_line == "MIT Learn: New Learning Resources from xpro: robotics"


def test_update_featured_rank(mocker, offeror_featured_lists):
"""The updated_featured_rank task should make the expected calls"""

Expand Down

0 comments on commit 5425fec

Please sign in to comment.