Skip to content
This repository has been archived by the owner on Dec 6, 2019. It is now read-only.

Commit

Permalink
optimized pilot stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Nabeel Shahzad committed Apr 14, 2011
1 parent 297bbfa commit aff2864
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions core/common/PilotData.class.php
Expand Up @@ -601,15 +601,28 @@ public static function updateFlightData($pilotid) {
*/
public static function updatePilotStats($pilotid) {

$sql = 'SELECT
COUNT(`pirepid`) as `totalpireps`
SEC_TO_TIME(SUM(TIME_TO_SEC(`flighttime_stamp`))) as `totaltime`
FROM `'.TABLE_PREFIX.'pireps`
WHERE `pilotid`='.$pilotid.' AND `accepted`='.PIREP_ACCEPTED;

$total = DB::get_row($sql);

return self::updateProfile($pilotid, array(
'totalhours' => $total->totaltime,
'totalflights' => $total->totalpireps,
));

/*$totalpireps = 0;
$totalhours = 0;
$pireps = PIREPData::findPIREPS(array(
'p.pilotid' => $pilotid,
'p.accepted' => PIREP_ACCEPTED
)
);
$totalpireps = 0;
$totalhours = 0;

if(is_array($pireps) && count($pireps) > 0) {
foreach ($pireps as $p) {
$totalpireps++;
Expand All @@ -623,6 +636,7 @@ public static function updatePilotStats($pilotid) {
);
return self::updateProfile($pilotid, $params);
*/
}


Expand Down

0 comments on commit aff2864

Please sign in to comment.