Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mbertrand committed Jan 2, 2025
1 parent eee1694 commit 6865867
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions learning_resources/etl/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,12 +823,12 @@ def parse_resource_duration(duration_str: str) -> DurationConfig:
DurationConfig: the standardized duration
"""
if duration_str:
duration_regex = re.compile(r"(\d+)\D+(\d+)?\s*(\w+)?", re.IGNORECASE)
duration_regex = re.compile(r"(\d+)\s*(to|-)*\s*(\d+)?\s*(\w+)?", re.IGNORECASE)
interval = transform_interval(duration_str)
match = duration_regex.match(duration_str.lower().strip())
if match and interval:
dmin = match.group(1)
dmax = match.group(2)
dmax = match.group(3)
return DurationConfig(
duration=duration_str,
min_weeks=calculate_weeks(int(dmin), interval.lower()),
Expand Down
2 changes: 2 additions & 0 deletions learning_resources/etl/utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,8 @@ def test_parse_string_to_int(hour, expected):
("2 - 3 semanas", 2, 3),
("Unparseable duration", None, None),
("", None, None),
("2 days in person+3 live webinars", 1, 1),
("2 weeks in person+3 live webinars", 2, 2),
],
)
def test_parse_resource_duration(raw_value, min_weeks, max_weeks):
Expand Down

0 comments on commit 6865867

Please sign in to comment.