feat: Expose source of stand assignment in API#1817
feat: Expose source of stand assignment in API#1817MrAdder wants to merge 12 commits intoVATSIM-UK:mainfrom
Conversation
|
Currently draft while I look into the Plugin side of things will also need changes in Lists_SMR and Lists as looking into adding this as a tag item |
What do you mean? Those fields are not currently in the API so there is no backwards compatibility? I'd probably scrap the Let's not overcomplicate the logic. Just a simple database field of the source + etxnesion to the API endpoints should suffice. |
|
I might just be missing it but where are we assigning the source field? I think I'm seeing only logic to expose it via the API but we gotta set it beforehand since I don't think we currently do that. |
Good shout — we are setting It’s persisted in the assignment write path here:
The value is derived from assignment type here:
So the API endpoints are returning stored data, not deriving source at read time. There’s also a DB-level fallback default of |
|
Moving this out of Draft for Copilot to look at this aswell |
There was a problem hiding this comment.
Pull request overview
Adds an assignment_source field to stand assignments so API consumers and real-time subscribers can tell where an assignment originated.
Changes:
- Added
assignment_sourcecolumn + model constants for canonical sources (manual,reservation_allocator,vaa_allocator,system_auto). - Populated
assignment_sourceduring assignment creation based on assignment type/allocator and exposed it in REST + broadcast payloads. - Updated unit/functional tests to assert the new field.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
app/Models/Stand/StandAssignment.php |
Adds source constants, fillable field, and an assignmentHistory relation. |
app/Services/Stand/StandAssignmentsService.php |
Sets assignment_source on create/update and tweaks unassign event dispatch. |
app/Http/Controllers/StandController.php |
Includes assignment_source in stand assignment REST responses and adjusts single-assignment payload shape. |
app/Events/StandAssignedEvent.php |
Adds assignment_source to broadcast payload. |
database/migrations/2026_03_16_120000_add_assignment_source_to_stand_assignments_table.php |
Adds the new DB column with a default value. |
tests/app/Services/Stand/StandAssignmentsServiceTest.php |
Adds coverage for source mapping behavior. |
tests/app/Http/Controllers/StandControllerTest.php |
Updates API response assertions for assignment_source and adjusts helper. |
tests/app/Events/StandAssignedEventTest.php |
Updates event payload expectations to include assignment_source. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
database/migrations/2026_03_16_120000_add_assignment_source_to_stand_assignments_table.php
Show resolved
Hide resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds persistence and API exposure for how each stand assignment was created, so plugin clients can distinguish manual vs allocator/system assignments (Fixes #1745).
Changes:
- Adds
assignment_sourcetostand_assignmentswith a DB default ofsystem_auto. - Populates
assignment_sourceon assignment creation inStandAssignmentsServiceviaassignmentSourceFromType(). - Exposes
assignment_sourceinGET /stand/assignment,GET /stand/assignment/{callsign}, andStandAssignedEventbroadcasts; updates tests accordingly.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
database/migrations/2026_03_16_120000_add_assignment_source_to_stand_assignments_table.php |
Adds the assignment_source column with default system_auto. |
app/Models/Stand/StandAssignment.php |
Defines source constants and makes assignment_source mass-assignable. |
app/Services/Stand/StandAssignmentsService.php |
Sets assignment_source on create/update; adds source mapping helper; tweaks unassign event helper signature. |
app/Http/Controllers/StandController.php |
Returns assignment_source in stand assignment API responses (and adjusts single-assignment payload). |
app/Events/StandAssignedEvent.php |
Includes assignment_source in broadcast payload. |
tests/app/Services/Stand/StandAssignmentsServiceTest.php |
Adds assertions/tests for persisted assignment_source on creation. |
tests/app/Http/Controllers/StandControllerTest.php |
Updates API response expectations to include assignment_source and adjusts helper. |
tests/app/Events/StandAssignedEventTest.php |
Updates broadcast payload assertions to include assignment_source. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
|
currently working on issue 604 on the plugin side |



PR Summary
Fixes #1745
Persists and exposes the source of each stand assignment so plugin clients can determine how an assignment was made.
What changed
assignment_sourcecolumn tostand_assignments(migration with DB default ofsystem_auto)StandAssignment:SOURCE_USER(manual) — explicitly assigned by a controllerSOURCE_RESERVATION_ALLOCATOR(reservation_allocator) — pilot-requested viaUserRequestedArrivalStandAllocatorSOURCE_VAA_ALLOCATOR(vaa_allocator) — VAA reservation allocatorsSOURCE_SYSTEM(system_auto) — system/auto allocation fallbackassignment_sourceis written on every assignment creation viaassignmentSourceFromType()inStandAssignmentsServiceassignment_sourceis now returned by:GET /stand/assignment(all assignments)GET /stand/assignment/{callsign}(single assignment)StandAssignedEventreal-time broadcastStandUnassignedEventkept minimal (callsign only — source not meaningful on unassign)assignmentHistoryrelation and eager loadBackward compatibility
Purely additive —
assignment_sourceis a new key alongside existing fields in all responses.Tests
assignment_sourcein responses