From 934da11471176a23eac69af19b8577e3a94b8222 Mon Sep 17 00:00:00 2001 From: "B.Fatih KOZ" Date: Sun, 12 Mar 2023 20:30:01 +0300 Subject: [PATCH] Pax and Cgo Stats --- README.md | 4 ++++ Resources/lang/de/widgets.php | 4 ++++ Resources/lang/en/widgets.php | 4 ++++ Resources/lang/es-es/widgets.php | 4 ++++ Resources/lang/fr/widgets.php | 4 ++++ Resources/lang/it/widgets.php | 4 ++++ Resources/lang/pt-br/widgets.php | 4 ++++ Resources/lang/pt-pt/widgets.php | 4 ++++ Services/DB_StatServices.php | 22 ++++++++++++++++++++++ 9 files changed, 54 insertions(+) diff --git a/README.md b/README.md index d6d23b8..64ab255 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/Resources/lang/de/widgets.php b/Resources/lang/de/widgets.php index 670e4fb..65cdc17 100644 --- a/Resources/lang/de/widgets.php +++ b/Resources/lang/de/widgets.php @@ -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', diff --git a/Resources/lang/en/widgets.php b/Resources/lang/en/widgets.php index 0ae8ae6..d3b5367 100644 --- a/Resources/lang/en/widgets.php +++ b/Resources/lang/en/widgets.php @@ -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', diff --git a/Resources/lang/es-es/widgets.php b/Resources/lang/es-es/widgets.php index f9e0208..fa61269 100644 --- a/Resources/lang/es-es/widgets.php +++ b/Resources/lang/es-es/widgets.php @@ -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', diff --git a/Resources/lang/fr/widgets.php b/Resources/lang/fr/widgets.php index 0e19892..8a1e04b 100644 --- a/Resources/lang/fr/widgets.php +++ b/Resources/lang/fr/widgets.php @@ -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', diff --git a/Resources/lang/it/widgets.php b/Resources/lang/it/widgets.php index 9e4e75f..b415bce 100644 --- a/Resources/lang/it/widgets.php +++ b/Resources/lang/it/widgets.php @@ -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', diff --git a/Resources/lang/pt-br/widgets.php b/Resources/lang/pt-br/widgets.php index 7f29a30..34ee762 100644 --- a/Resources/lang/pt-br/widgets.php +++ b/Resources/lang/pt-br/widgets.php @@ -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', diff --git a/Resources/lang/pt-pt/widgets.php b/Resources/lang/pt-pt/widgets.php index 0f5311c..3e00578 100644 --- a/Resources/lang/pt-pt/widgets.php +++ b/Resources/lang/pt-pt/widgets.php @@ -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', diff --git a/Services/DB_StatServices.php b/Services/DB_StatServices.php index cd86383..7efbc8d 100644 --- a/Services/DB_StatServices.php +++ b/Services/DB_StatServices.php @@ -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 = []; @@ -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');