Skip to content

FEAT:🌙 Prefer remote stands overnight for configured airfields#1814

Open
MrAdder wants to merge 21 commits intoVATSIM-UK:mainfrom
MrAdder:issue-1762
Open

FEAT:🌙 Prefer remote stands overnight for configured airfields#1814
MrAdder wants to merge 21 commits intoVATSIM-UK:mainfrom
MrAdder:issue-1762

Conversation

@MrAdder
Copy link
Contributor

@MrAdder MrAdder commented Feb 23, 2026

Summary

Adds overnight stand-order weighting so stands marked as overnight-remote are prioritised during configured night hours.

Migration

  • Adds overnight_remote_preferred (boolean, default false) to stands.
  • This is a stand-level option, so it can be enabled per stand at any airport.

Behavior

  • Controlled by stands.night_remote_stand_weighting.enabled.
  • During configured Europe/London night window (start_hourend_hour), stands with overnight_remote_preferred = true are preferred.
  • Outside that window, standard allocation ordering remains unchanged.

Why

Provides a simple, data-driven way to support overnight remote-stand preference without airport-specific hard-coding.

full push of feature
Refactored nightTimeRemoteStandOrderCondition() to reduce return paths and satisfy the “max 3 returns” rule by consolidating guard conditions into booleans ($isEnabledForAirfield, $shouldApplyRemoteWeighting) before the final SQL fragment generation.
- Fixed the root cause of the failing night-weighting test by correcting the airfield lookup in nightTimeRemoteStandOrderCondition(): it now uses planned_destairport (which is populated on NetworkAircraft) instead of arrival_airfield (which was not), so the night remote weighting can actually activate.

- Made the airfield match case-insensitive by normalizing both the aircraft destination and configured airfield list to uppercase before comparison, preventing config/case mismatches from disabling the feature.
@19wintersp
Copy link
Contributor

Would it not be better to define a new property for stands indicating whether they are remote/preferred for overnight parking? Hijacking the assignment priority for this purpose seems a little perverse when it is also used (as I understand it) for marking stands as temporarily out-of-use, or for larger stands in mixed-size stand arrangements

@MrAdder
Copy link
Contributor Author

MrAdder commented Feb 24, 2026

Would it not be better to define a new property for stands indicating whether they are remote/preferred for overnight parking? Hijacking the assignment priority for this purpose seems a little perverse when it is also used (as I understand it) for marking stands as temporarily out-of-use, or for larger stands in mixed-size stand arrangements

I can implement that logic instead I just did it this way originally as it seemed logical with what was asked didn't think of this way round

Change to a more logical approach to the Night time stands
@MrAdder
Copy link
Contributor Author

MrAdder commented Feb 25, 2026

Updated PR Text in regards to changes

@MrAdder MrAdder changed the title 🌙 Prefer remote stands overnight for configured airfields (feature-flagged) 🌙 Prefer remote stands overnight for configured airfields Feb 25, 2026
@MrAdder MrAdder changed the title 🌙 Prefer remote stands overnight for configured airfields FEAT:🌙 Prefer remote stands overnight for configured airfields Feb 25, 2026
Copy link
Contributor

@kristiankunc kristiankunc left a comment

Choose a reason for hiding this comment

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

Please remove the env config, let!s just enable this out of the box.

Removed env config now enabled out of box
Removed redundant config fields
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

Adds an “overnight remote preference” signal to stands and introduces a night-time ordering bias intended to prefer those stands during a configured window.

Changes:

  • Adds stands.overnight_remote_preferred column, model cast/fillable, factory default, and Filament UI toggle/column.
  • Adds a night-window ORDER BY fragment to prefer overnight_remote_preferred stands.
  • Adds functional tests covering “night prefers flagged stand” vs “daytime unchanged”.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
app/Allocator/Stand/SelectsStandsUsingStandardConditions.php Introduces night-window ORDER BY bias preferring overnight_remote_preferred.
config/stands.php Adds night window configuration keys.
database/migrations/2026_02_25_000001_add_overnight_remote_preferred_to_stands.php Adds new boolean column + index.
app/Models/Stand/Stand.php Adds fillable + boolean cast for new column.
database/factories/Stand/StandFactory.php Sets factory default for new column.
app/Filament/Resources/StandResource.php Adds toggle to form and boolean column to table.
lang/en/stands/form.php Adds form label/helper copy for new toggle.
lang/en/stands/table.php Adds table column label.
tests/app/Allocator/Stand/FallbackArrivalStandAllocatorTest.php Adds tests for night/day ordering behavior.

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

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

Adds an opt-in “overnight remote stand” preference to arrival stand allocation, allowing configured airfields to bias allocations during a Europe/London night window toward stands explicitly flagged as overnight-remote.

Changes:

  • Introduces stands.overnight_remote_preferred (DB column + model cast/fillable + factory default) and exposes it in Filament.
  • Adds a conditional ORDER BY fragment to prefer overnight_remote_preferred stands during a configured night window for configured destination airfields.
  • Adds functional tests for in-window vs out-of-window allocation behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
tests/app/Allocator/Stand/FallbackArrivalStandAllocatorTest.php Adds tests covering overnight preference and non-preference outside the night window.
app/Allocator/Stand/SelectsStandsUsingStandardConditions.php Prepends an optional night-window ORDER BY fragment for overnight_remote_preferred.
database/migrations/2026_02_25_000001_add_overnight_remote_preferred_to_stands.php Adds the new boolean column + index to stands.
app/Models/Stand/Stand.php Makes the new field mass-assignable and casts it to boolean.
database/factories/Stand/StandFactory.php Sets default overnight_remote_preferred to false.
app/Filament/Resources/StandResource.php Adds toggle + table column for the new flag in the admin UI.
config/stands.php Adds configuration for night-window weighting.
lang/en/stands/form.php Adds label/helper text for the new toggle.
lang/en/stands/table.php Adds table column label for the new flag.

💡 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.

kristiankunc
kristiankunc previously approved these changes Mar 16, 2026
@kristiankunc kristiankunc requested a review from CLC0609 March 16, 2026 17:23
Copy link
Contributor

@CLC0609 CLC0609 left a comment

Choose a reason for hiding this comment

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

Other than that one comment all looks good!

@MrAdder
Copy link
Contributor Author

MrAdder commented Mar 22, 2026 via email

CLC0609
CLC0609 previously approved these changes Mar 23, 2026
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

Adds an optional “overnight remote stand” preference to the stand allocator, allowing certain stands to be preferred during a configured night window (intended to be opt-in and scoped per airfield).

Changes:

  • Introduces stands.overnight_remote_preferred and surfaces it in the Stand model, factory defaults, and Filament admin UI.
  • Adds a time-window-based ORDER BY bias to prefer overnight_remote_preferred stands overnight.
  • Adds functional tests asserting overnight preference vs daytime behavior.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
tests/app/Allocator/Stand/FallbackArrivalStandAllocatorTest.php Adds tests for overnight preference behavior.
lang/en/stands/table.php Adds table column label for the new flag.
lang/en/stands/form.php Adds form label/helper text for the new flag.
database/migrations/2026_02_25_000001_add_overnight_remote_preferred_to_stands.php Adds the overnight_remote_preferred column and index.
database/factories/Stand/StandFactory.php Defaults overnight_remote_preferred to false.
config/stands.php Adds night-window configuration for the weighting feature.
app/Models/Stand/Stand.php Makes the new flag fillable and casts it to boolean.
app/Filament/Resources/StandResource.php Adds toggle + table column for the new flag in the admin UI.
app/Allocator/Stand/SelectsStandsUsingStandardConditions.php Implements the overnight ORDER BY bias in standard allocator ordering.

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

Updated comments to clarify time zone handling for overnight window.
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

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.


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

@sonarqubecloud
Copy link

@MrAdder
Copy link
Contributor Author

MrAdder commented Mar 24, 2026

Ok now all sorted dropped the index as suggested by Copilot as its right I do not need it for this to function

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.

5 participants