Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter Events by active ones (starts after now) #668

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/clubs/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2426,7 +2426,7 @@ def destroy(self, request, *args, **kwargs):
return super().destroy(request, *args, **kwargs)

def get_queryset(self):
qs = Event.objects.all()
qs = Event.objects.filter(start_time__gte=timezone.now())
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idk if past events are ever used but the page takes forever to load rn

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently past events aren't accessible via the frontend...however with ticketing this will change, so I don't think this should be default behavior. Instead we could add this as a query parameter + an index on start time? @aviupadhyayula feel free to chime in

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to me. I'm not a huge fan of filtering out past events by default.

Also, this is probably an issue with our serializer, and not the query.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rm03's suggestion sounds pretty good. For context, Jacky is trying to use this route to render events on iOS but the page is just too massive to load since it contains all events ever

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we have some unnoticed N+1s here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we have some unnoticed N+1s here?

Doesn't look like it, just checked locally

is_club_specific = self.kwargs.get("club_code") is not None
if is_club_specific:
qs = qs.filter(club__code=self.kwargs["club_code"])
Expand Down
Loading