Skip to content

Feat/add scans#30

Merged
balebbae merged 11 commits intomainfrom
feat/add-scans
Feb 24, 2026
Merged

Feat/add scans#30
balebbae merged 11 commits intomainfrom
feat/add-scans

Conversation

@balebbae
Copy link
Copy Markdown
Collaborator

Summary

  • Add scan tracking system for hackathon day-of operations (check-in, meals, swag
    distribution)
  • Implement scans table with unique constraint per user+type, plus O(1) stats via a counter
    cache in the settings table
  • Add admin endpoints for creating scans, viewing user scan history, and retrieving aggregate
    stats
  • Add super-admin endpoint for configuring scan types (check_in, meal, swag categories)

New API Routes

Method: GET
Route: /v1/admin/scans/types
Role: admin
Description: List configured scan types

Method: POST
Route: /v1/admin/scans
Role: admin
Description: Record a scan for a user

Method: GET
Route: /v1/admin/scans/user/{userID}
Role: admin
Description: Get all scans for a user

Method: GET
Route: /v1/admin/scans/stats
Role: admin
Description: Aggregate scan counts by type

Method: PUT
Route: /v1/superadmin/settings/scan-types
Role: super_admin
Description: Replace scan type configuration

Key Design Decisions

  • Check-in gate: Non-check_in scans (meals, swag) require the user to have a check_in scan
    first
  • One scan per type per user: Enforced at DB level via UNIQUE(user_id, scan_type), returns 409
    on duplicates
  • O(1) stats: Scan counts are maintained as a counter cache in settings.scan_stats,
    incremented atomically inside the create-scan transaction — avoids COUNT(*) aggregation on
    every poll
  • Configurable scan types: Stored as JSONB in the settings table with three categories:
    check_in, meal, swag

Migrations

  • 000013 — scans table with indexes on user_id and scan_type
  • 000014 — Seeds default scan_types setting (single "Check In" type)
  • 000015 — Seeds empty scan_stats counter cache

Copy link
Copy Markdown
Collaborator

@anishalle anishalle left a comment

Choose a reason for hiding this comment

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

everything else lgtm.

Comment thread cmd/api/scans.go
Stats []store.ScanStat `json:"stats"`
}

type UpdateScanTypesPayload struct {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it it common to have two of the same type of struct? one for update and one for get? This is structurally similar to ScanStatsResponse except for the validate:.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I mean it could be one but I'm just following existing pattern. Also in the future if I want to add other fields to the response in the future it's easier. Like a created_at.

Comment thread cmd/api/applications.go
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Did you intentionally remove the first line of the headers:
Examples:

// getOrCreateApplicationHandler returns the user's application, creating a draft if none exists

// updateApplicationHandler updates the user's draft application

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Uh yeah I feel like the swagger descriptions pretty self explanatory already. Also I don't like when comments restate the function. Lowkey claudes faults.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

wait claudes smarter than me... Apparently it's needed 🫩. I'll go add them again.

Comment thread cmd/api/auth.go
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same questions about the first line

Comment thread cmd/api/reviews.go
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same as previous comments

Comment thread cmd/api/scans.go
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

only first method has the first line in the header

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

OPs I gotta delete that

Comment thread cmd/api/settings.go
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

same question about headers

@anishalle
Copy link
Copy Markdown
Collaborator

@copilot Review this PR

(I wanna see what it says)

Copy link
Copy Markdown

Copilot AI commented Feb 24, 2026

@anishalle I've opened a new pull request, #34, to work on those changes. Once the pull request is ready, I'll request review from you.

@balebbae balebbae merged commit 4d4a24c into main Feb 24, 2026
2 checks passed
balebbae added a commit that referenced this pull request Feb 27, 2026
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.

4 participants