nabeelio / phpvms

virtual airline management
http://www.phpvms.net
BSD 3-Clause "New" or "Revised" License
172 stars 143 forks source link

Enhanced statistics #815

Open dotalchemy opened 4 years ago

dotalchemy commented 4 years ago

Enhanced pilot statistics

Perhaps the ability to drill down per aircraft type per user, see how many miles User X has flown in an A320, how many passengers they've flown in a 208, etc.

Airport statistics

Airframe statistics (per tail number)

The latter could expand into a maintenance module later down the road, where aircraft must have annual / 100hr inspections, perhaps even SMOH times on engines

Maybe monthly versions of the above items for graphing / trending / reporting?

nabeelio commented 4 years ago

Just some thoughts/notes for me:

abstract class Stats {
  public $statName;  // Hold the stat name
  abstract function calculate(User $user): Stat;

  public function runCalculation(User $user) {
    // run the calculate() method
    $stat = $this->calculate($user);

    // sanity checks, insert into DB
  }
}

And a model/enum:

public class IntervalEnum {
  // minute, hourly, daily, monthly, yearly
}

public class Stat extends Model {
  public $fillable = ['name', 'interval-type', 'interval-time', 'value'];
}

Impl:

class TotalFlights extends Stats {
  public $statName = 'total-flights';

  public function calculate(User $user): Stat {
    $stat = new Stat(['interval-type' => IntervalEnum::$daily, 'interval-time' = Carbon::today()]);
    // calc..
    $stat->value = $user->total_flights;  // dumb... but return some kind of value

    return $stat;
  }
}
avs-code commented 4 years ago

more pilot statistics? Top pilots landing rating (Gs forces or vertical speed?) Top pilots hours Top pilots flights