Jump to content

Recommended Posts

Posted

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

  • 3 months later...
Posted

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

  • Administrators
Posted

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.

Posted

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.

  • Administrators
Posted

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.

  • Administrators
Posted

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.

Posted

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.

  • 2 months later...
  • Administrators
Posted

Thats odd, have you downloaded the files and installed them into your system? It almost looks like you have put a link to the GitHub account in the page.

Posted

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.

  • Administrators
Posted

Did you run the script to populate the database to start? Have you filed any PIREPS since installing the module to automatically run the script to populate the table?

Posted

Yes,

i have run script.

Filed pirep?

I have used kAcars to make my flights.

I have make 2 flights after install script but May i dont see nothing.

Thx

Regards

Posted

Hi,

yes i do.

Yes there was some data.

id pilot_id flights hours miles month year 1 104 1 1 491 4 2012 2 105 2 1 402 4 2012 3 106 4 5 1316 4 2012 4 117 4 1 44 4 2012 5 106 1 1 257 5 2012 6 117 2 1 22 5 2012

Any idea?

Thx

  • Administrators
Posted

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.

Posted

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.

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