Skip to content

Log individual votes#12

Merged
slashtechno merged 8 commits intomainfrom
log-votes
Apr 5, 2025
Merged

Log individual votes#12
slashtechno merged 8 commits intomainfrom
log-votes

Conversation

@slashtechno
Copy link
Collaborator

Keep track of individual votes instead of just incrementing project points.

slashtechno and others added 2 commits March 16, 2025 13:34
@vercel
Copy link

vercel bot commented Mar 19, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
showcase ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 5, 2025 4:14am

@slashtechno
Copy link
Collaborator Author

Before I merge this I need to disable voting for all events and set the points column to default to the legacy points. Then, an announcement needs to be made stating that any future votes will result in legacy votes being lost.

@slashtechno slashtechno requested a review from Copilot March 31, 2025 14:45
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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(

raise (
HTTPException(status_code=404, detail="Project not found")
if e.response.status_code == 404
if e.response.status_code == 404 or 403
Copy link

Copilot AI Mar 31, 2025

Choose a reason for hiding this comment

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

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]'.

Suggested change
if e.response.status_code == 404 or 403
if e.response.status_code in [404, 403]

Copilot uses AI. Check for mistakes.
raise (
HTTPException(status_code=404, detail="Event not found")
if e.response.status_code == 404
if e.response.status_code == 404 or 403
Copy link

Copilot AI Mar 31, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
if e.response.status_code == 404 or 403
if e.response.status_code in [404, 403]

Copilot uses AI. Check for mistakes.
HTTPException(status_code=404, detail="Project not found")
if e.response.status_code == 404
else e
if e.response.status_code == 404 or 403:
Copy link

Copilot AI Mar 31, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
if e.response.status_code == 404 or 403:
if e.response.status_code in [404, 403]:

Copilot uses AI. Check for mistakes.
chore: update base and table IDs in settings.toml
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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(

Comment on lines +42 to 43
votes: MultiRecordField = []
collaborators: MultiRecordField = []
Copy link

Copilot AI Apr 5, 2025

Choose a reason for hiding this comment

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

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.

Suggested change
votes: MultiRecordField = []
collaborators: MultiRecordField = []
votes: MultiRecordField = Field(default_factory=list)
collaborators: MultiRecordField = Field(default_factory=list)

Copilot uses AI. Check for mistakes.
@slashtechno slashtechno merged commit df0c261 into main Apr 5, 2025
1 of 2 checks passed
@slashtechno slashtechno moved this to Done in Podium Apr 5, 2025
@pizzalover125 pizzalover125 moved this from Done to In Progress in Podium Apr 11, 2025
@pizzalover125 pizzalover125 moved this from In Progress to Done in Podium Apr 11, 2025
@pizzalover125 pizzalover125 moved this from Done to In Progress in Podium Apr 11, 2025
@pizzalover125 pizzalover125 moved this from In Progress to Done in Podium Apr 11, 2025
@slashtechno slashtechno deleted the log-votes branch May 4, 2025 15:46
@slashtechno slashtechno added the enhancement New feature or request label Jun 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants