-
Notifications
You must be signed in to change notification settings - Fork 1
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
Fix/list all events in previous events view #100
base: master
Are you sure you want to change the base?
Conversation
🗃️ Add 15 new past events to seed data for testing ✨ Implement /past-events/count endpoint to get the count of past events ✨ Implement /past-events endpoint to retrieve past events with pagination ✅ Add tests for the two new API endpoints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! 🚀 Left some comments that should be fixed
db = get_database(request) | ||
|
||
# Get current UTC datetime | ||
current_datetime = datetime.now(timezone.utc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This endpoint uses timezone.utc
, but none of the others do. This might lead to wrong results here
# Apply search filter according to role | ||
search_filter = {"date": {"$lt": current_datetime}} | ||
if token and token.role != Role.admin: | ||
search_filter["public"] = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure this is leads to a valid mongodb query. You can copy the search filter logic from the get_past_events
endpoint instead
""" Get last 10 events that have passed """ | ||
def get_past_events(request: Request, token: AccessTokenPayload = Depends(optional_authentication), | ||
skip: int = Query(0, ge=0), | ||
limit: int = Query(10,ge=1,le=50)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like I commented on the frontend, another design here that might be simpler is to simply use a hardcoded limit, instead of allowing clients to supply it in the query parameters. If you choose to simplify it, remember to do it both on the api and the frontend.
No description provided.