Conversation
Co-authored-by: Gaurav Pandey <hi@pandeygaurav.com>
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
|
Before I merge this I need to disable voting for all events and set the |
There was a problem hiding this comment.
Pull Request Overview
This PR implements a system to log individual votes rather than merely incrementing project points. Key changes include:
- Creating new types (e.g. CreateVotes) and updating API endpoints to accept and process individual vote data.
- Updating backend routers to handle vote validations and error conditions alongside adding new vote models and configuration.
- Adjusting database models and configuration files to integrate a dedicated votes table.
Reviewed Changes
Copilot reviewed 13 out of 16 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/src/lib/client/types.gen.ts | Added vote-related types and additional vote fields for events. |
| backend/settings.toml | Added development configuration for the votes table. |
| backend/podium/routers/projects.py | Updated error handling in project retrieval for vote operations. |
| backend/podium/routers/events.py | Modified vote route logic to use CreateVotes; revised validations. |
| backend/podium/routers/auth.py | Added checks to ensure the user exists before processing auth tokens. |
| backend/podium/db/vote.py | Introduced new vote models and types. |
| backend/podium/db/user.py | Cleaned up user lookup logic using new match formulas. |
| backend/podium/db/project.py | Added a voters field to track individual votes on projects. |
| backend/podium/db/event.py | Added a computed property for max votes per user based on projects count. |
| backend/podium/db/db.py | Configured the votes table in the database setup. |
| backend/podium/db/init.py | Imported vote models and assigned the votes table. |
| backend/podium/config.py | Added a validator for the airtable_votes_table_id setting. |
Files not reviewed (3)
- .vscode/launch.json: Language not supported
- frontend/src/lib/components/ProjectCard.svelte: Language not supported
- frontend/src/routes/events/[id]/rank/+page.svelte: Language not supported
Comments suppressed due to low confidence (1)
backend/podium/routers/events.py:226
- [nitpick] The variable 'vote' is redefined inside the loop, shadowing the function parameter and potentially causing confusion; consider renaming it (e.g. 'vote_record').
vote = VoteCreate(
backend/podium/routers/projects.py
Outdated
| raise ( | ||
| HTTPException(status_code=404, detail="Project not found") | ||
| if e.response.status_code == 404 | ||
| if e.response.status_code == 404 or 403 |
There was a problem hiding this comment.
Using 'or 403' will always evaluate to True, leading to incorrect handling; please compare explicitly, for example: 'if e.response.status_code in [404, 403]'.
| if e.response.status_code == 404 or 403 | |
| if e.response.status_code in [404, 403] |
backend/podium/routers/events.py
Outdated
| raise ( | ||
| HTTPException(status_code=404, detail="Event not found") | ||
| if e.response.status_code == 404 | ||
| if e.response.status_code == 404 or 403 |
There was a problem hiding this comment.
This condition always returns True due to 'or 403'; use an explicit comparison such as 'if e.response.status_code in [404, 403]' to correctly handle error statuses.
| if e.response.status_code == 404 or 403 | |
| if e.response.status_code in [404, 403] |
backend/podium/routers/events.py
Outdated
| HTTPException(status_code=404, detail="Project not found") | ||
| if e.response.status_code == 404 | ||
| else e | ||
| if e.response.status_code == 404 or 403: |
There was a problem hiding this comment.
This conditional check always evaluates to True; please use an explicit comparison like 'if e.response.status_code in [404, 403]' to correctly capture the error conditions.
| if e.response.status_code == 404 or 403: | |
| if e.response.status_code in [404, 403]: |
chore: update base and table IDs in settings.toml
There was a problem hiding this comment.
Copilot reviewed 13 out of 17 changed files in this pull request and generated 1 comment.
Files not reviewed (4)
- .vscode/launch.json: Language not supported
- frontend/src/lib/components/CreateProject.svelte: Language not supported
- frontend/src/lib/components/ProjectCard.svelte: Language not supported
- frontend/src/routes/events/[id]/rank/+page.svelte: Language not supported
Comments suppressed due to low confidence (3)
backend/podium/routers/projects.py:156
- It appears that the key for the project id is unquoted. To correctly pass the id field, use a string key ("id": project["id"]) to ensure proper dictionary syntax.
return Project.model_validate({id: project["id"], **project["fields"]})
backend/podium/routers/events.py:210
- The identifier 'User' is used without a visible import; ensure that the correct user model is imported or referenced for proper validation.
user = User.model_validate({"id": user["id"], **user["fields"]})
backend/podium/routers/events.py:226
- [nitpick] The reuse of the variable name 'vote' inside the loop (while the endpoint parameter is 'votes') can be confusing; consider renaming it (e.g., 'vote_record').
vote = VoteCreate(
| votes: MultiRecordField = [] | ||
| collaborators: MultiRecordField = [] |
There was a problem hiding this comment.
Using a mutable default (an empty list) for the votes field may lead to unexpected behavior; consider using a default factory (e.g., Field(default_factory=list)) to avoid shared mutable state.
| votes: MultiRecordField = [] | |
| collaborators: MultiRecordField = [] | |
| votes: MultiRecordField = Field(default_factory=list) | |
| collaborators: MultiRecordField = Field(default_factory=list) |
Keep track of individual votes instead of just incrementing project points.