-
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
app/api/events.py
Outdated
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
app/api/events.py
Outdated
# 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
app/api/events.py
Outdated
""" 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.
This commit will: - Refactor the `get_past_events` endpoint to use a fixed query limit - Now uses localtime instead of utctime in `get_past_events` endpoint - Refactor the 'get_past_events' endpoint to use the same mongodb-query logic as the rest of the functions for consistency - Update pagination parameters in the test suite to reflect the new fixed limit and validate functionality. - Ensure tests verify filtering and pagination logic with updated query constraints.
No description provided.