Skip to content

Event location fix#133

Merged
adescoteaux1 merged 7 commits intomainfrom
event-location-fix
Mar 25, 2026
Merged

Event location fix#133
adescoteaux1 merged 7 commits intomainfrom
event-location-fix

Conversation

@adescoteaux1
Copy link
Collaborator

moving location from events to orgs, making location required for orgs

@adescoteaux1 adescoteaux1 linked an issue Mar 24, 2026 that may be closed by this pull request
@github-actions
Copy link

Backend Test Results

Test Summary ✅

  • Passed: 302
  • Failed: 0
  • Skipped: 0
  • Status: All tests passed!

Coverage ⚠️

  • Total Coverage: 50.9%
  • Status: Coverage is below recommended threshold (70%)

Coverage report and test logs have been uploaded as artifacts.

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 updates the data model and API so event occurrences no longer carry their own location_id, and instead location is associated with the organization (and intended to be required there). It also regenerates the frontend API client/types and updates backend SQL, handlers, and tests accordingly.

Changes:

  • Drop event_occurrence.location_id and update queries to resolve location via event -> organization -> location.
  • Make organization location_id non-optional in backend models/handlers and update related tests/utilities.
  • Regenerate/update frontend API client code and OpenAPI schema to reflect updated event occurrence inputs.

Reviewed changes

Copilot reviewed 31 out of 46 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
frontend/packages/api-client/src/generated/skillSparkAPI.schemas.ts Regenerated API schemas (includes event occurrence location removal and additional review schema changes).
frontend/packages/api-client/src/generated/schools/schools.ts Regenerated query client wrapper formatting/typing.
frontend/packages/api-client/src/generated/saved/saved.ts Regenerated query/mutation client wrapper formatting/typing.
frontend/packages/api-client/src/generated/managers/managers.ts Regenerated query/mutation client wrapper formatting/typing.
frontend/packages/api-client/src/generated/locations/locations.ts Regenerated query/mutation client wrapper formatting/typing.
frontend/packages/api-client/src/generated/health/health.ts Regenerated query client wrapper formatting/typing.
frontend/packages/api-client/src/generated/guardians/guardians.ts Regenerated query/mutation client wrapper formatting/typing.
frontend/packages/api-client/src/generated/events/events.ts Regenerated events client; event occurrence endpoints remain but payload types align with schema regen.
frontend/packages/api-client/src/generated/auth/auth.ts Regenerated auth mutation wrappers formatting/typing.
backend/internal/supabase/seed/09_event_occurrence.sql Seed update removing location_id from event_occurrence inserts.
backend/internal/supabase/migrations/20260324155444_event-location-update.sql Migration dropping event_occurrence.location_id.
backend/internal/storage/postgres/schema/organization/util.go Test helper now creates a location and sets organization.location_id.
backend/internal/storage/postgres/schema/organization/update_test.go Tests updated for required org location_id and updated location assertions.
backend/internal/storage/postgres/schema/organization/update.go Fix assignment to match non-pointer Organization.LocationID.
backend/internal/storage/postgres/schema/organization/sql/get_by_organization_id.sql Query updated to join org and derive location via org.
backend/internal/storage/postgres/schema/organization/delete_test.go Tests updated to create org with a location.
backend/internal/storage/postgres/schema/organization/create_test.go Tests updated for required org location_id and non-pointer assertions.
backend/internal/storage/postgres/schema/event/sql/get_by_event_id.sql Query updated to derive location via org (currently contains a SQL syntax issue).
backend/internal/storage/postgres/schema/event-occurrence/util.go Test helper no longer creates/sets event_occurrence.location_id.
backend/internal/storage/postgres/schema/event-occurrence/update_test.go Tests updated to remove location_id update/assertions.
backend/internal/storage/postgres/schema/event-occurrence/update.go Repository update no longer passes location_id into SQL.
backend/internal/storage/postgres/schema/event-occurrence/sql/update.sql SQL update no longer updates/returns location_id; joins location via org.
backend/internal/storage/postgres/schema/event-occurrence/sql/get_by_id.sql Query updated to join org and derive location via org.
backend/internal/storage/postgres/schema/event-occurrence/sql/get_all.sql Query updated to join org and derive location via org.
backend/internal/storage/postgres/schema/event-occurrence/sql/create.sql Insert/return updated to exclude location_id; joins location via org.
backend/internal/storage/postgres/schema/event-occurrence/get_by_id_test.go Tests updated to remove location assertions.
backend/internal/storage/postgres/schema/event-occurrence/delete_test.go Tests updated to remove location from create inputs.
backend/internal/storage/postgres/schema/event-occurrence/create_test.go Tests updated to remove location from create inputs/assertions.
backend/internal/storage/postgres/schema/event-occurrence/create.go Repository create no longer passes location_id into SQL.
backend/internal/service/routes/organizations.go Route now passes non-pointer LocationID into create body.
backend/internal/service/routes/organization_routes_test.go Route tests updated for required org location and new expectations.
backend/internal/service/routes/event_occurrences_routes_test.go Validation tests updated to remove event occurrence location_id usage/mocking.
backend/internal/service/handler/organization/handler_test.go Handler tests updated for required org location and new expectations.
backend/internal/service/handler/organization/createOrganization.go Handler now always validates location_id existence (no nil-check).
backend/internal/service/handler/event-occurrence/update.go Removes location FK existence check for event occurrence updates.
backend/internal/service/handler/event-occurrence/handler_test.go Handler tests updated to remove location inputs/assertions.
backend/internal/service/handler/event-occurrence/create.go Removes location FK existence check for event occurrence creates.
backend/internal/models/organization.go Organization and create body updated to make location_id non-optional.
backend/internal/models/event_occurrence.go Removes location_id from create/update event occurrence inputs.
backend/api/openapi.yaml OpenAPI updated to remove location_id from event occurrence schemas.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 48 to 52
type CreateOrganizationBody struct {
Name string `json:"name" minLength:"1" maxLength:"255" doc:"Organization name"`
Active *bool `json:"active,omitempty" doc:"Active status (defaults to true)"`
LocationID *uuid.UUID `json:"location_id,omitempty" format:"uuid" doc:"Associated location ID"`
Name string `json:"name" minLength:"1" maxLength:"255" doc:"Organization name"`
Active *bool `json:"active,omitempty" doc:"Active status (defaults to true)"`
LocationID uuid.UUID `json:"location_id" format:"uuid" doc:"Associated location ID"`
}
Copy link

Copilot AI Mar 24, 2026

Choose a reason for hiding this comment

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

CreateOrganizationBody.LocationID is now non-optional, but the multipart form structs (CreateOrganizationFormData / UpdateOrganizationFormData) still don't mark location_id as required. That means requests could omit it and end up with a zero UUID, producing a less clear "location does not exist" error instead of a validation error, and the generated OpenAPI may not mark it as required. Consider adding required:"true" (and any other relevant validation) to the form field and regenerating the OpenAPI/client.

Copilot uses AI. Check for mistakes.
adescoteaux1 and others added 5 commits March 24, 2026 17:00
…t_id.sql

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…by_organization_id.sql

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…get_all.sql

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@adescoteaux1 adescoteaux1 requested a review from josh-torre March 24, 2026 21:06
@github-actions
Copy link

Backend Test Results

Test Summary ✅

  • Passed: 302
  • Failed: 0
  • Skipped: 0
  • Status: All tests passed!

Coverage ⚠️

  • Total Coverage: 50.9%
  • Status: Coverage is below recommended threshold (70%)

Coverage report and test logs have been uploaded as artifacts.

3 similar comments
@github-actions
Copy link

Backend Test Results

Test Summary ✅

  • Passed: 302
  • Failed: 0
  • Skipped: 0
  • Status: All tests passed!

Coverage ⚠️

  • Total Coverage: 50.9%
  • Status: Coverage is below recommended threshold (70%)

Coverage report and test logs have been uploaded as artifacts.

@github-actions
Copy link

Backend Test Results

Test Summary ✅

  • Passed: 302
  • Failed: 0
  • Skipped: 0
  • Status: All tests passed!

Coverage ⚠️

  • Total Coverage: 50.9%
  • Status: Coverage is below recommended threshold (70%)

Coverage report and test logs have been uploaded as artifacts.

@github-actions
Copy link

Backend Test Results

Test Summary ✅

  • Passed: 302
  • Failed: 0
  • Skipped: 0
  • Status: All tests passed!

Coverage ⚠️

  • Total Coverage: 50.9%
  • Status: Coverage is below recommended threshold (70%)

Coverage report and test logs have been uploaded as artifacts.

Copy link
Collaborator

@josh-torre josh-torre left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@adescoteaux1 adescoteaux1 merged commit 3981895 into main Mar 25, 2026
6 checks passed
@adescoteaux1 adescoteaux1 deleted the event-location-fix branch March 25, 2026 02:15
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.

Clean: Move Locations form Event Occurrences to Organizations

3 participants