Jump to content

TOPPilot beta 1.0


simpilot

Recommended Posts

Did you try to populate the database again after changing the table prefix? If so, is there anything in the new top_pilots table? If there is, do a print_r or var_dump in the template for the variable and see what comes out. That will show if there is any data available and guide you on where to look for the problem.

Nothing there it's empty

Link to comment
Share on other sites

  • 3 months later...

Not exactly sure what you are asking but I think you are asking if the counts are made before or after the PIREP is accepted. The module currently counts all PIREPS that are pending or approved, the instructions and consequences are in the initial post of this thread.

I'm having some doubts about what to change so it does only count accepted pireps

        $start = StatsData::GetStartDate();
       $startmonth = date('m', strtotime($start->submitdate));
       $startyear = date('Y', strtotime($start->submitdate));
       $today = getdate();

       while ($startyear <= $today[year] ) {

           $pilots = PilotData::getAllPilots();
           $month_stats = TopPilotData::get_monthly_stats($startmonth, $startyear);

           foreach ($pilots as $pilot) {
               $totaltime=0;
               $totalflights=0;
               $totalmiles=0;
               if(isset($month_stats)) {
                   foreach ($month_stats as $pirep) {
                       if ($pilot->pilotid == $pirep->pilotid  /* && $pirep->accepted == 1 */ ) {
                           $totaltime = $totaltime + $pirep->flighttime;
                           $totalflights++;
                           $totalmiles = $totalmiles + $pirep->distance;
                       }
                   }
               }
               if($totalflights > 0) {
                   TopPilotData::record_stats($pilot->pilotid, $totalflights, $totaltime, $totalmiles, $startmonth, $startyear);
               }
           }
           if ($startmonth == 12) {$startyear++; $startmonth = 1;}
           else {$startmonth++;}
       }
   }

My guess is that it has something to do with "/* && $pirep->accepted == 1 */".

You said to change something on line 52 but that is an empty line in my toppilot.php

Link to comment
Share on other sites

  • Administrators

Remove the /* and the */ comment marks from that line and it will not add the PIREP when it is submitted by the pilot. I am rewriting this module now anyway as it has started to create issues for sites that have a large amount (10k +) and timeouts.

Link to comment
Share on other sites

Dave,

Found it. I have changed line 60 of toppilot.php into

regards,

Cor

I've added this piece of code and the problem is almost fixed, but the times are still off.

It works for calculating the hours and minutes correctly, but it forgets the seconds in the pireps flight time. They are not added.... which results in 5 min difference on 10 flights allready.

Link to comment
Share on other sites

  • Administrators

I've also noticed that when I uncomment the line to make the script look at accepted pireps only, the script doesn't work automatic anymore.

Are looking prior to anopther PIREP being accepted?

Excluding PIREPS that are not accepted yet.

TopPilot.php line 52.

Uncomment the trailing section and the module will not include unapproved PIREPS. Doing this will cause the module not to display any newly accepted PIREPS in the TopPilot data listings until after another PIREP is filed although you can refresh the stats at anytime using yoursite/index.php/TopPilot/refresh_pilot_stats

Using this method the PIREP will not be included in the stats until another one is accepted.

Link to comment
Share on other sites

  • Administrators

so the stats are always 1 pirep late that way?

Simple answer, yes.

There is currently no admin side controller for this module so there is no way to catch the PIREP Approved event from that side. You could write an admin side module to read that event and then do the necesarry calculations.

Link to comment
Share on other sites

I've added this piece of code and the problem is almost fixed, but the times are still off.

It works for calculating the hours and minutes correctly, but it forgets the seconds in the pireps flight time. They are not added.... which results in 5 min difference on 10 flights allready.

Any updates on the monthly stats not showing correcly? It seems that Util::date can't handle the seconds.

We 've got an difference of 7 minutes allready with 45h flown.

It shows very hard now since it's our first month and the alltimesstats are shown above, that will get better next month. But still, I'm a perfectionist and like things to be correct.

Link to comment
Share on other sites

  • 2 months later...

Hi,

i have done that and work.

I have put sopy files out of original folders.

But noe i have this problem:

In this month, May, i have done 2 flights but dot apear in list.

Only this info: No Pireps Filed For May 2012

Is not possible.

Because i have done 2 flights.

Any idea?

Thx very much.

King regards.

Link to comment
Share on other sites

  • Administrators

Have you changed your database tables prefix from the default "phpvms_"? I am thinking Yes.

In /core/common/TopPilotData.class.php file change line 15 from

query = "SELECT * FROM phpvms_pireps WHERE MONTH(submitdate) = '$month' AND YEAR(submitdate) = '$year'";

to

query = "SELECT * FROM ".TABLE_PREFIX."pireps WHERE MONTH(submitdate) = '$month' AND YEAR(submitdate) = '$year'";

I have updated the code on github.

Link to comment
Share on other sites

Hi,

you have an erro in code:

query = "SELECT * FROM ".TABLE_PREFIX.'pireps WHERE MONTH(submitdate) = '$month' AND YEAR(submitdate) = '$year'";

The right code is:

$query = "SELECT * FROM .TABLE_PREFIX.'pireps WHERE MONTH(submitdate) = '$month' AND YEAR(submitdate) = '$year'";

Now work wonderful.

Thx very much for you help.

One doubt please:

I have this in airline stats: Total Fuel Burned: 31782.3054199219

How i can see less numbers?

Regards.

Link to comment
Share on other sites

  • Administrators

Use the php round function to reduce the number of decimal places.

echo round($my_variable);

will give you no decimal places

echo round($my_variable, 2);

will give you 2 decimal places, and so on.

You can also use the number format function if you want to add thousands seperators and such. http://php.net/manual/en/function.number-format.php

Link to comment
Share on other sites

  • 3 weeks later...

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...