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

Fix/list all events in previous events view #100

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

TorgrimRL
Copy link

No description provided.

    🗃️ 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
Copy link
Contributor

@otytlandsvik otytlandsvik left a 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)
Copy link
Contributor

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
Copy link
Contributor

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)):
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants