Skip to content

Commit 004556d

Browse files
tonyqiu123claude
andcommitted
fix: include events without dtend_utc in upcoming events filter
Events without an end time are now included in the response if their start time is within 90 minutes before now. This ensures events without dtend_utc are properly shown as "live" for 90 minutes after they start. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent ab3f756 commit 004556d

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

backend/apps/events/views.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,16 @@ def get_events(request):
7373
# Upcoming events filter: show all live and future events by default
7474
if not dtstart_utc_param:
7575
now = timezone.now()
76+
ninety_minutes_ago = now - timedelta(minutes=90)
7677
events_queryset = events_queryset.filter(
7778
Q(
7879
event_dates__dtstart_utc__lte=now, event_dates__dtend_utc__gte=now
79-
) # Live
80+
) # Live events with dtend_utc
81+
| Q(
82+
event_dates__dtstart_utc__gte=ninety_minutes_ago,
83+
event_dates__dtstart_utc__lte=now,
84+
event_dates__dtend_utc__isnull=True
85+
) # Live events without dtend_utc (started within last 90 minutes)
8086
| Q(event_dates__dtstart_utc__gte=now) # Upcoming
8187
).distinct()
8288
else:
@@ -175,18 +181,24 @@ def get_events(request):
175181

176182
for event in events_list:
177183
all_dates = list(event.event_dates.all())
184+
ninety_minutes_ago = now - timedelta(minutes=90)
178185
# Find the next upcoming or currently live date
179186
upcoming_or_live_dates = [
180187
date
181188
for date in all_dates
182189
if date.dtstart_utc
183190
and (
184-
date.dtstart_utc >= now
191+
date.dtstart_utc >= now # Future events
185192
or (
186193
date.dtstart_utc <= now
187194
and date.dtend_utc
188195
and date.dtend_utc >= now
189-
)
196+
) # Live events with dtend_utc
197+
or (
198+
date.dtstart_utc >= ninety_minutes_ago
199+
and date.dtstart_utc <= now
200+
and not date.dtend_utc
201+
) # Live events without dtend_utc (started within last 90 minutes)
190202
)
191203
]
192204
selected_date = (

0 commit comments

Comments
 (0)