Jump to content

TouchdownStats 1.0


simpilot

Recommended Posts

I've tried to install the TouchdownStats, get the following message:

Warning: Invalid argument supplied for foreach() in /var/www/html/web907/html/freedomair/core/templates/touchdownstats/touchdownstats_index.tpl on line 21

I have the pireps will file manually, here and read the tread but what it does not work for me.

can anyone help me what files must I change in as

Link to comment
Share on other sites

  • 1 month later...

How about something like this Mark;

Add to TouchdownstataData.class.php

  function get_averages($howmany) {

       $avg = array();

       $pilots = PilotData::findPilots(array('retired' => '0'));

       foreach($pilots as $pilot)
           {
               $query = "SELECT AVG(landingrate) as average, pilotid FROM ".TABLE_PREFIX."pireps WHERE landingrate < '0' AND pilotid='$pilot->pilotid'";
               $result = DB::get_row($query);
               if($result->pilotid != '')
               {$avg[] = $result;}
           }

       rsort($avg);

       return array_slice($avg, '0', $howmany);
   }

Add to TouchdownStats.php

   function averages($howmany)   {
       $this->set('stats', TouchdownStatsData::get_averages($howmany));
       $this->show('touchdownstats/touchdownstats_averages.tpl');
   }

Add a new template in core/templates/touchdownstats called touchdownstats_averages.tpl

<h3>Best Average Landing Rate</h3>
<?php
if($stats)
{
   echo '<table>';
   echo '<tr>';
   echo '<th>Landing Rate</th>';
   echo '<th>Pilot</th>';
   echo '</tr>';
       foreach($stats as $stat)
       {
           $pilot = PilotData::getPilotData($stat->pilotid);
           echo '<tr>';
           echo '<td>'.round($stat->average, 1).'</td>';
           echo '<td>'.PilotData::getPilotCode($pilot->code, $pilot->pilotid).' - '.$pilot->firstname.' '.$pilot->lastname.'</td>';
           echo '</tr>';
       }
   echo '</table>';
}
else
{
   echo 'No Stats Available';
}
?>

Then call it by url and pass how many records you want as the last element

http://www.yoursite.com/index.php/touchdownstats/averages/10

or within another template

<?php MainController::run('touchdownstats', 'averages', '10'); ?>

Hi Dave!

does not work for me, no result, only exits "No Stats Available"

http://s3.imagestime.com/out.php/i631825_Immagine.png

thanks and happy new year

Link to comment
Share on other sites

  • 5 weeks later...

Hi Simpilot,

I have a problem with the montly stat.

This is the code that is use in the Touchdownstatsdata.class

public function get_stats_by_cur_month_limited($howmany){

$query = "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`

WHERE landingrate < '0'

AND YEAR(submitdate)=YEAR(curdate())

AND MONTH(submitdate)=MONTH(curdate())

ORDER BY landingrate DESC"

LIMIT $howmany";

At the page its showing also the landigsrate of februari 2011. Can you or somebody else help me.

Tnx in advange,

regards,

Cor

Link to comment
Share on other sites

  • 1 month later...

is there any chance that someone can help me?

im trying to remove duplicates that are shown

example

this is what my stats look like at the moment

pilot1 -57

pilot3 -59

pilot2 -125

pilot1 -132

pilot3 -138

pilot2 -148

this is what i would like it to look like

pilot1 -57

pilot3 -59

pilot2 -125

ect ect

please help as the top 20 list that i have is full of the same 3 pilots

thanks

Steve

Link to comment
Share on other sites

That's never going to happen since the TD Stats shows the best landings of All Time.

pilot1 -57 ---> Best landing ever

pilot3 -59 ---> 2nd best landing

pilot2 -125 --->3rd best landing

pilot1 -132 --->4th best landing

pilot3 -138 --->5th best landing

pilot2 -148 --->6th best landing

It doesn't matter who the pilot is, it only matters what the best landing is, so that's what it is going to show.
Link to comment
Share on other sites

  • 1 month later...

How can you make to display a text " No Flights" if the pilot hasn't flown yet on the pilots average landing rate? Now if the pilot has no flights it shows an error.

I am using this to display the pilots average landing rate in the public profile.

<?php echo ''.round(TouchdownStatsData::pilot_average($userinfo->pilotid), 2); ?>

Link to comment
Share on other sites

  • Administrators

I have change dthe code a little in TouchdownstatsData.class.php to solve the error and return a '0' instead of an error. It has been updated on GitHub to reflect the following.

   public function pilot_average($pilotid) {
    $stats = self::pilot_stats($pilotid);
    $total = 0;
    $count = 0;
    if(!empty($stats))
    {
	    foreach ($stats as $stat)
		    {
		    $total = $total + $stat->landingrate;
		    $count++;
	    }
	    return $total / $count;
    }
    else
    {return '0';}
   }

You could do something like this in your template to get the 'No Flights' message;

<?php

$avg_rate = TouchdownStatsData::pilot_average($userinfo->pilotid);

if($avg_rate == '0')
{echo 'No Flights';}
else
{echo round($avg_rate, 2);}

?>

Link to comment
Share on other sites

How are you including it on your frontpage?

something like

<?php MainController::run('touchdownstats', 'index'); ?>

should be all you need if the data is there.

you might want to include this to your HOW TO INSTALL section...took me hours to find this....had to read through all the pages...and this was all i needed!! THANX

Link to comment
Share on other sites

  • 1 month later...
  • 10 months later...

I have a issue with this addon, In logs of pilots you can see a descent rate, but in admin page/recent pireps have different data. Touchdown stats give the admin/recent pireps value.

Pilot #1

In LOG:

16:10 Flaps:3 at 242 Knots

16:13 Flaps:4 at 218 Knots

16:16 TouchDown:Rate -923 ft/min Speed: 204 Knots

16:17 Land

In admin recent pireps:

No additional data found Client: fsacars Aircraft: B747-400 (A002) Flight Time: 02:45:00 Distance: 801 Landing Rate: 0

Pilot #2

In LOG:

09:14 Flaps:7 at 180 Knots

09:14 Flaps:8 at 174 Knots

09:20 TouchDown:Rate -381 ft/min Speed: 152 Knots

09:20 Land

In admin recent pireps:

No additional data found Client: fsacars Aircraft: B747-400 (A002) Flight Time: 01:45:00 Distance: 672 Landing Rate: -3

How i can fix this? its impossible win with this descent rates :P

Regards

Link to comment
Share on other sites

  • Administrators

@ARV187

This is not really an issue with the Touchdown Stats module as it only grabs the info that is in the pireps database. I would take a look at what is actually in the landing rate column of your PIREPS table and go backwards from there. I would guess it is how your ACARS log is being parsed or you have manually changed some pilot id's somewhere along the way and flights are getting crossed up between pilots.

Link to comment
Share on other sites

Seems that only occurs sometimes with fsacars, has not changed the pilot id after their first flight, then could be the parsed data how you said.

We only changed to pay hosting, but I think that should not affect.

phpvms_pireps.sql.zip

Another curiosity, with ifly 737-800, fsPassengerX only show this:

CompanyName=ARGAVIRTUAL<br />nPilotName=ARV0006<br />nFlightId=ARV1434<br />nOnlineNetworkNbr=0<br />nFlightDate=2013-05-22<br />nAircraftName=iFly 737-800 (Normal screen) bar

But apparently sends all data to database. Curious, its not it?

Link to comment
Share on other sites

  • Administrators

Not really sure what you want to reset. If you want to erase all your PIREPS you could just trunacate the table from phpmyadmin or similar. If you want to set all the landing rates back to 0 then run a sql query to reset them -> somthing like -> UPDATE table SET landingrate = 0;

Link to comment
Share on other sites

  • 5 months later...
  • Administrators

How i can limit the number of the tochdownstats 10 pilots to 5 pilot.

Not sure exactly what you are looking for but the function "top_landings($howmany)" will return the top landings in order and limit it by the "$howmany" variable.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...