diff --git a/backend/app/services/recurrence.py b/backend/app/services/recurrence.py index cb0406d..0246d25 100644 --- a/backend/app/services/recurrence.py +++ b/backend/app/services/recurrence.py @@ -84,6 +84,11 @@ def generate_occurrences( original_start=occ_start, ) + # Always generate a child for the parent's own start date (the first occurrence). + # The parent template is hidden from list views, so without this the first date + # would have no visible event. + occurrences.append(_make_child(parent_start)) + if rule_type == "every_n_days": interval: int = int(rule.get("interval") or 1) if interval < 1: @@ -95,10 +100,10 @@ def generate_occurrences( elif rule_type == "weekly": weekday: int = int(rule.get("weekday") if rule.get("weekday") is not None else parent_start.weekday()) - # Start from the week after the parent + # Start from the next week after the parent days_ahead = (weekday - parent_start.weekday()) % 7 if days_ahead == 0: - days_ahead = 7 # skip the parent's own week + days_ahead = 7 current = parent_start + timedelta(days=days_ahead) while current < horizon: occurrences.append(_make_child(current))