Skip to content

feat: Expose source of stand assignment in API#1817

Draft
MrAdder wants to merge 1 commit intoVATSIM-UK:mainfrom
MrAdder:issue-1745
Draft

feat: Expose source of stand assignment in API#1817
MrAdder wants to merge 1 commit intoVATSIM-UK:mainfrom
MrAdder:issue-1745

Conversation

@MrAdder
Copy link
Contributor

@MrAdder MrAdder commented Feb 27, 2026

Fixes #1745

🧾 Summary of changes (Expose “reservation allocator” source on stand assignments)

🔎 API responses now indicate if an assignment came from the reservation allocator

  • Updates StandController responses to include a new boolean:
    • assigned_by_reservation_allocator

This flag is set by checking the latest assignment history record and detecting whether the type starts with:

  • App\\Allocator\\Stand\\UserRequestedArrivalStandAllocator

🚚 GET /stand/assignment (all assignments)

  • Now eager-loads assignment history:
    • StandAssignment::with('assignmentHistory')->get()
  • Each returned assignment includes:
    • callsign
    • stand_id
    • assigned_by_reservation_allocator (true/false)

✈️ GET /stand/assignment/{callsign} (single assignment)

  • Loads the latest assignment history for the returned assignment and includes:
    • id, airfield, identifier
    • assigned_by_reservation_allocator

🧩 Model enhancement: latest assignment history relationship

  • Adds StandAssignment::assignmentHistory() relationship:
    • hasOne(StandAssignmentsHistory::class, 'callsign', 'callsign')->latestOfMany('assigned_at')
  • This provides a clean way to fetch the most recent assignment provenance.

⚙️ Service optimisation

  • StandAssignmentsService::assignmentForCallsign() now eager-loads:
    • assignmentHistory
  • Helps avoid N+1 queries and ensures provenance is available wherever assignments are fetched.

🧪 Tests added/updated

  • Existing assignment list + single assignment tests updated to expect:
    • assigned_by_reservation_allocator => false by default
  • Adds two new tests to validate provenance detection:
    • testItReturnsReservationAllocatorSourceInStandAssignments
    • testItReturnsReservationAllocatorSourceForSingleAssignmentRoute
  • Uses StandAssignmentsHistory::create() with type App\Allocator\Stand\UserRequestedArrivalStandAllocator to assert the flag becomes true.

✅ Net effect

Consumers (UI / plugin / API clients) can now distinguish normal user/auto assignments from those created via the reservation allocator, without changing existing endpoints or payload structure beyond the additive boolean field.

@sonarqubecloud
Copy link

@MrAdder
Copy link
Contributor Author

MrAdder commented Feb 27, 2026

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

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.

Expose source of stand assignment in API

1 participant