Skip to content

Commit

Permalink
Pax and Cgo Stats
Browse files Browse the repository at this point in the history
  • Loading branch information
FatihKoz committed Mar 12, 2023
1 parent aed3b68 commit 934da11
Show file tree
Hide file tree
Showing 9 changed files with 54 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,10 @@ If you have duplicated blades and encounter problems after updating the module o

## Release / Update Notes

12.MAR.23

* Added total/average passenger and freight figures to statistics

24.FEB.23

* Added a new option to Map Widget (Airports)
Expand Down
4 changes: 4 additions & 0 deletions Resources/lang/de/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
'stats_rep' => 'PIREP Statistik',
'pireps_ack' => 'Pireps (angenommen)',
'pireps_rej' => 'Pireps (abgelehnt)',
'pireps_pax' => 'Total Passengers',
'avg_pax' => 'Avg. Passengers',
'pireps_cgo' => 'Total Freight',
'avg_cgo' => 'Avg. Freight',
'atime' => 'Durchschnittl. Blockzeit',
'ttime' => 'Gesamte Blockzeit',
'afuel' => 'Durchschnittl. Treibstoffverbrauch',
Expand Down
4 changes: 4 additions & 0 deletions Resources/lang/en/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
'stats_rep' => 'PIREP Statistics',
'pireps_ack' => 'Pireps (Accepted)',
'pireps_rej' => 'Pireps (Rejected)',
'pireps_pax' => 'Total Passengers',
'avg_pax' => 'Avg. Passengers',
'pireps_cgo' => 'Total Freight',
'avg_cgo' => 'Avg. Freight',
'atime' => 'Avg. Block Time',
'ttime' => 'Total Block Time',
'afuel' => 'Avg. Fuel Burn',
Expand Down
4 changes: 4 additions & 0 deletions Resources/lang/es-es/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
'stats_rep' => 'Estadísticas de PIREP',
'pireps_ack' => 'Pireps (Aceptados)',
'pireps_rej' => 'Pireps (Rechazados)',
'pireps_pax' => 'Total Passengers',
'avg_pax' => 'Avg. Passengers',
'pireps_cgo' => 'Total Freight',
'avg_cgo' => 'Avg. Freight',
'atime' => 'Tiempo medio entre calzos',
'ttime' => 'Tiempo total entre calzos',
'afuel' => 'Consumo medio de combustible',
Expand Down
4 changes: 4 additions & 0 deletions Resources/lang/fr/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
'stats_rep' => 'Statistiques des PIREPs',
'pireps_ack' => 'Pireps (Acceptés)',
'pireps_rej' => 'Pireps (Rejetés)',
'pireps_pax' => 'Total Passengers',
'avg_pax' => 'Avg. Passengers',
'pireps_cgo' => 'Total Freight',
'avg_cgo' => 'Avg. Freight',
'atime' => 'Temps moyen porte à porte',
'ttime' => 'Temps total porte à porte',
'afuel' => 'Consommation Moyenne',
Expand Down
4 changes: 4 additions & 0 deletions Resources/lang/it/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
'stats_rep' => 'Statistiche PIREP',
'pireps_ack' => 'Pireps (Accettato)',
'pireps_rej' => 'Pireps (Rifiutato)',
'pireps_pax' => 'Total Passengers',
'avg_pax' => 'Avg. Passengers',
'pireps_cgo' => 'Total Freight',
'avg_cgo' => 'Avg. Freight',
'atime' => 'Media Tempo ai Blocchi',
'ttime' => 'Tempo ai blocchi Totale',
'afuel' => 'Media Carburante Usato',
Expand Down
4 changes: 4 additions & 0 deletions Resources/lang/pt-br/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
'stats_rep' => 'Estatísticas do PIREP',
'pireps_ack' => 'Pireps (Aceitos)',
'pireps_rej' => 'Pireps (Rejeitados)',
'pireps_pax' => 'Total Passengers',
'avg_pax' => 'Avg. Passengers',
'pireps_cgo' => 'Total Freight',
'avg_cgo' => 'Avg. Freight',
'atime' => 'Tempo de Voo Médio',
'ttime' => 'Tempo de Voo Total',
'afuel' => 'Média de Combustível Consumido',
Expand Down
4 changes: 4 additions & 0 deletions Resources/lang/pt-pt/widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
'stats_rep' => 'Estatísticas de Relatórios',
'pireps_ack' => 'Relatórios (Aprovados)',
'pireps_rej' => 'Relatórios (Rejeitados)',
'pireps_pax' => 'Total Passengers',
'avg_pax' => 'Avg. Passengers',
'pireps_cgo' => 'Total Freight',
'avg_cgo' => 'Avg. Freight',
'atime' => 'Média Tempo de Voo',
'ttime' => 'Total Horas de Voo',
'afuel' => 'Média Consumo Combustível',
Expand Down
22 changes: 22 additions & 0 deletions Services/DB_StatServices.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ public function PirepStats($airline_id = null, $aircraft_id = null)
$stats = [];
$level = 100;
$unit_distance = setting('units.distance');
$unit_weight = setting('units.weight');
$unit_fuel = setting('units.fuel');

$where = [];
Expand Down Expand Up @@ -390,6 +391,27 @@ public function PirepStats($airline_id = null, $aircraft_id = null)
}
*/

// Count carried PAX and CGO for fancy stats
$paxfares = DB::table('fares')->select('id')->where('type', 0)->pluck('id')->toArray();
$cgofares = DB::table('fares')->select('id')->where('type', 1)->pluck('id')->toArray();
$allpireps = DB::table('pireps')->select('id')->where($where)->pluck('id')->toArray();

$pax_amount = DB::table('pirep_fares')->whereIn('pirep_id', $allpireps)->whereIn('fare_id', $paxfares)->sum('count');
$pax_avg = DB::table('pirep_fares')->whereIn('pirep_id', $allpireps)->whereIn('fare_id', $paxfares)->avg('count');
$cgo_amount = DB::table('pirep_fares')->whereIn('pirep_id', $allpireps)->whereIn('fare_id', $cgofares)->sum('count');
$cgo_avg = DB::table('pirep_fares')->whereIn('pirep_id', $allpireps)->whereIn('fare_id', $cgofares)->avg('count');

if ($pax_amount > 0) {
$stats[__('DBasic::widgets.pireps_pax')] = number_format($pax_amount);
$stats[__('DBasic::widgets.avg_pax')] = number_format($pax_avg);
}

if ($cgo_amount > 0) {
$stats[__('DBasic::widgets.pireps_cgo')] = number_format($cgo_amount) . ' ' . $unit_weight;
$stats[__('DBasic::widgets.avg_cgo')] = number_format($cgo_avg) . ' ' . $unit_weight;
}

// Basic Pirep Statistics
$total_time = DB::table('pireps')->where($where)->sum('flight_time');
$total_dist = DB::table('pireps')->where($where)->sum('distance');
$total_fuel = DB::table('pireps')->where($where)->sum('fuel_used');
Expand Down

0 comments on commit 934da11

Please sign in to comment.