Skip to content

Commit ba4bd47

Browse files
committed
fix get_events
1 parent c9b79ad commit ba4bd47

File tree

6 files changed

+325
-5
lines changed

6 files changed

+325
-5
lines changed

backend/apps/events/views.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ def get_events(request):
5151
if not dtstart_utc_param:
5252
now = timezone.now()
5353
ninety_minutes_ago = now - timedelta(minutes=90)
54-
# Filter events that have at least one upcoming date
54+
# Filter events that are either:
55+
# 1. Have no end time and started within last 90 minutes
56+
# 2. Have end time and are currently happening (between start and end)
5557
events_queryset = events_queryset.filter(
56-
event_dates__dtstart_utc__gte=ninety_minutes_ago
58+
Q(event_dates__dtend_utc__isnull=True, event_dates__dtstart_utc__gte=ninety_minutes_ago)
59+
| Q(event_dates__dtend_utc__isnull=False, event_dates__dtstart_utc__lte=now, event_dates__dtend_utc__gte=now)
5760
).distinct()
5861

5962
filterset = EventFilter(request.GET, queryset=events_queryset)
@@ -148,9 +151,13 @@ def get_events(request):
148151
for event in events_list:
149152
# Get all event dates and filter for upcoming ones
150153
all_dates = list(event.event_dates.all())
151-
# Filter to only upcoming dates (>= ninety_minutes_ago to match the filter logic)
154+
# Filter to only upcoming/live dates matching the query logic:
155+
# 1. No end time and started within last 90 minutes
156+
# 2. Has end time and currently happening (between start and end)
152157
upcoming_dates = [
153-
date for date in all_dates if date.dtstart_utc >= ninety_minutes_ago
158+
date for date in all_dates
159+
if (date.dtend_utc is None and date.dtstart_utc >= ninety_minutes_ago)
160+
or (date.dtend_utc is not None and date.dtstart_utc <= now and date.dtend_utc >= now)
154161
]
155162
# Select the most recent upcoming date (first one since they're ordered by dtstart_utc)
156163
# If no upcoming dates, fall back to the earliest date overall

frontend/package-lock.json

Lines changed: 182 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frontend/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
"dependencies": {
1414
"@clerk/clerk-react": "^5.53.3",
1515
"@clerk/themes": "^2.4.30",
16+
"@codemirror/lang-json": "^6.0.2",
17+
"@codemirror/state": "^6.5.2",
18+
"@codemirror/theme-one-dark": "^6.1.3",
19+
"@codemirror/view": "^6.38.7",
1620
"@hookform/resolvers": "^5.2.2",
1721
"@number-flow/react": "^0.5.10",
1822
"@radix-ui/react-checkbox": "^1.3.3",
@@ -30,6 +34,7 @@
3034
"axios": "^1.7.7",
3135
"class-variance-authority": "^0.7.1",
3236
"clsx": "^2.1.1",
37+
"codemirror": "^6.0.2",
3338
"date-fns": "^4.1.0",
3439
"date-fns-tz": "^3.2.0",
3540
"framer-motion": "^12.23.24",

frontend/src/features/events/pages/EventsPage.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import {
1515
FloatingEventExportBar,
1616
formatRelativeDateTime,
1717
FilterButton,
18+
// JSONEditor,
1819
} from "@/shared";
1920
import { Calendar, LayoutGrid, Sparkles, Heart, Clock } from "lucide-react";
2021
import SearchInput from "@/features/search/components/SearchInput";
@@ -103,6 +104,7 @@ function EventsPage() {
103104
"campus activities",
104105
]}
105106
/>
107+
{/* <JSONEditor /> */}
106108
<div className="flex flex-col gap-4">
107109
<div className="sm:text-left">
108110
<h1 className="sm:text-3xl text-2xl font-bold mb-2 -mt-3 sm:mt-0">

0 commit comments

Comments
 (0)