Skip to content

Commit cec1efc

Browse files
authored
Fix: Only show published events in related events (#69)
1 parent 7911285 commit cec1efc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

events/v1/utils.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def get_similar_events(event_slug: str) -> list[Event]:
1212
event = get_object_or_404(Event, slug=event_slug)
1313
exclude_current = ~Q(id=event.id)
1414
similarity_query = Q()
15+
published_filter = Q(status=Event.EventStatus.PUBLISHED)
1516

1617
if event.playlists.exists():
1718
similarity_query |= Q(playlists__in=event.playlists.all())
@@ -20,8 +21,8 @@ def get_similar_events(event_slug: str) -> list[Event]:
2021
if event.tags.exists():
2122
similarity_query |= Q(tags__in=event.tags.all())
2223

23-
similar_events = Event.objects.filter(exclude_current & similarity_query).distinct()
24-
latest_events = Event.objects.filter(exclude_current).order_by('-event_time')[:5]
24+
similar_events = Event.objects.filter(exclude_current & similarity_query & published_filter).distinct()
25+
latest_events = Event.objects.filter(exclude_current & published_filter).order_by('-event_time')[:5]
2526

2627
combined_events = list(similar_events) + list(latest_events)
2728
unique_events = {event.id: event for event in combined_events}.values()

0 commit comments

Comments
 (0)