Jump to content

Landing rates by month and all time


Recommended Posts

Guest Stormchaser
Posted

My pilots love the landing rate module and have had a few requests to do it by month instead for all time. I have pilot stats module and landing rates combined on one page. Wondering if there is a way to combine top pilot module and landing rate module into one so landing rate pulls by month. Not much of a coder before I started this but learning how to copy and paste pretty good to manipulate code. Just asking if someone has done this already save me a great deal of time.

And by the way always like to say thanks for phpvms!

Posted

For now, gives you current month.

Assuming you are using the Touchdown stats from David Clark...

Add the following to the file TouchdownStatsData.class.php located under common (BACKUP FIRST!!!!) MARK! Both inpastes must go over the last '}' brackets in the bottom of files.

//Added by [your name] 2011.xx.xx
get_stats_by_cur_month ()



$query =  "SELECT pilotid, code, flightnum, depicao, arricao, aircraft, landingrate, submitdate FROM `".TABLE_PREFIX."pireps`
WHERE landingrate < '0' and MONTH(submitdate)=MONTH(curdate())
ORDER BY landingrate DESC";

return DB::get_results($query);}

Then add to the following file under module, TouchdownStats TouchdownStats.php

//Added by [your name] 2011.xx.xx
public function top_landing_this_month ()
{ 

$this->set('stats', TouchdownStatsData::get_stats_by_cur_month());
$this->show('touchdownstats/touchdownstats_index.tpl');
}

Link to http://your.site.ok/TouchdownStats/top_landing_this_month

The month selection require a bit more work. If you want limit the returned data, use same technique as above and paste in addition in TouchdownStatsData.class.php:

//Added by [your name] 2011.xx.xx
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 MONTH(submitdate)=MONTH(curdate())
                   ORDER BY landingrate DESC";

	return DB::get_results($query);
	}

And in th file TouchdownStats.php:

public function top_landing_this_month_limited ()
{ 

	$this->set('stats', TouchdownStatsData::get_stats_by_cur_month_limited($howmany));
	$this->show('touchdownstats/touchdownstats_index.tpl');
}

To link limits use /top_landing_this_month_limited/X where x is the number you want to limit it to.

Must say my database is rather slim, so I don't know how this will look in a big DB. Anyway copy the files you are manipulating, ALWAYS.

Sorry for the brief answer, will come up with the month selection later. Make a mark that the scritp will return an error if the dataset is empty in the foreach clause in the tpl file. So probably you will get an error in the begining of each month :).

Regards

  • Like 1
  • Moderators
Posted

Right i have had to do a bit of syntax adjustment but its working to a point, the top function seems to pull back all the landings from every month, doesnt seem to limit by current month.

I will keep playing and see what i can do :)

Posted

Since my database is quite sparse, I am not sure, but I think the following sql will give you best landing grouped by month and pilot for a given year. You can test if you have webmin, phpmyadmin or heidi SQl Whatevere. Perhaps that is interestning?

SELECT pilotid, date_format(submitdate,'%M') as month, code, flightnum, depicao, arricao, aircraft, max(landingrate) as 'best landing', format(avg(landingrate),2) as 'average', submitdate FROM `pireps` 
group by month(submitdate),(pilotid) having year(submitdate)=2011 

Change year to whatever you like...

  • Moderators
Posted

Right i have this working and limiting nicely now :)

I want to put this page in another page but i cant seem to get it to work, any ideas would be great, i have tried,

<?php MainController::Run('TouchdownStats', 'display_TouchdownStats/top_landing_this_month'); ?>

here is the page,

http://www.easyjetva.com/index.php/TouchdownStats/top_landing_this_month

cheers.

Posted

Sorry didn't explain fully, i want that data on another page but i cant include it as it needs to be ran as a url,

Yes, you have to change to URL. Assumingen the files has been copied in the directories as described, you just add /index.php/TouchdownStats/top_landing_this_month to you site's URL. When I click on the URL you sent the page comes up fine?

Regards

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