Block aircraft with Simbrief (#1213)
* Block Aircraft with SimBrief Changes aim to have the ability to block an aircraft's usage if it is used to generate a SimBrief OFP. Unused/Expired briefings will be deleted by cron like before but will now be checked by HourlyCron, so admins can define more precise restrictions for them (and the blockage period of their aircraft) Owner of the SimBrief OFP will be able to start a flight with acars using that particular aircraft, but pilots will get an Aircraft Not Available error (similar to Aircraft State check) To prevent SimBrief OFP packs being marked as expired/unused, during pirep prefile, pirep_id will be saved to SimBrief model along with flight_id. And when a flight is finished (pirep file), flight_id will be removed from SimBrief model as before. Only pirep_id will remain and aircraft will be available for another OFP generation. * Update PirepController In case a pirep is being saved/submitted with manual entry (but the va is using simbrief effectively) same logic should be applied during save/submit button selection. Save will act like a pirep prefile , Submit will be pirep file. * Manual Pirep Checks Manual pireps, prefiled from a generated simbrief should be checked too. Also pirep.show blade's submit button should provide the same simbrief checks. * Update PirepService.php * Change settings and move sb cron to hourly * StyleFix (SimBriefService) * Another StyleFix (SimBriefService) * Update SimBriefController Removed null check of pirep_id for aircraft list generation to prevent live flights' aircraft being listed for another ofp generation. ( Active acars flights will have both flight_id and pirep_id at simbrief table) * Update PirepService.php Co-authored-by: Nabeel S <nabeelio@users.noreply.github.com>
This commit is contained in:
@@ -132,21 +132,23 @@ class SimBriefService extends Service
|
||||
*
|
||||
* 1. Read from the XML the basic PIREP info (dep, arr), and then associate the PIREP
|
||||
* to the flight ID
|
||||
* 2. Remove the flight ID from the SimBrief field and assign the pirep_id to the row
|
||||
* 2. Remove the flight ID from the SimBrief model and assign the pirep ID to the row
|
||||
* at the end of the flight. Keep flight ID until the flight ends (pirep file).
|
||||
* 3. Update the planned flight route in the acars table
|
||||
* 4. Add additional flight fields (ones which match ACARS)
|
||||
*
|
||||
* @param $pirep
|
||||
* @param SimBrief $simBrief The briefing to create the PIREP from
|
||||
* @param SimBrief $simBrief The briefing to create the PIREP from
|
||||
* @param bool $keep_flight True keeps the flight_id, default is false
|
||||
*
|
||||
* @return \App\Models\Pirep
|
||||
*/
|
||||
public function attachSimbriefToPirep($pirep, SimBrief $simBrief): Pirep
|
||||
public function attachSimbriefToPirep($pirep, SimBrief $simBrief, $keep_flight = false): Pirep
|
||||
{
|
||||
$this->addRouteToPirep($pirep, $simBrief);
|
||||
|
||||
$simBrief->pirep_id = $pirep->id;
|
||||
$simBrief->flight_id = null;
|
||||
$simBrief->flight_id = !empty($keep_flight) ? $pirep->flight_id : null;
|
||||
$simBrief->save();
|
||||
|
||||
return $pirep;
|
||||
@@ -185,14 +187,14 @@ class SimBriefService extends Service
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove any expired entries from the SimBrief table. Expired means there's
|
||||
* a flight_id attached to it, but no pirep_id (meaning it was never used for
|
||||
* an actual flight)
|
||||
* Remove any expired entries from the SimBrief table.
|
||||
* Expired means there's a flight_id attached to it, but no pirep_id
|
||||
* (meaning it was never used for an actual flight)
|
||||
*/
|
||||
public function removeExpiredEntries(): void
|
||||
{
|
||||
$expire_days = setting('simbrief.expire_days', 5);
|
||||
$expire_time = Carbon::now('UTC')->subDays($expire_days);
|
||||
$expire_hours = setting('simbrief.expire_hours', 6);
|
||||
$expire_time = Carbon::now('UTC')->subHours($expire_hours);
|
||||
|
||||
$briefs = SimBrief::where([
|
||||
['pirep_id', null],
|
||||
@@ -202,7 +204,7 @@ class SimBriefService extends Service
|
||||
foreach ($briefs as $brief) {
|
||||
$brief->delete();
|
||||
|
||||
// TODO: Delete any assets
|
||||
// TODO: Delete any assets (Which assets ?)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user