MyBB Community Forums
[Suggestions?] - Posts/Threads/Members per day over last week - Printable Version

+- MyBB Community Forums (https://community.mybb.com)
+-- Forum: Extensions (https://community.mybb.com/forum-201.html)
+--- Forum: Plugins (https://community.mybb.com/forum-73.html)
+---- Forum: Plugin Development (https://community.mybb.com/forum-68.html)
+---- Thread: [Suggestions?] - Posts/Threads/Members per day over last week (/thread-18733.html)



[Suggestions?] - Posts/Threads/Members per day over last week - Yumi - 2007-04-28

I decided to modify stats.php to show posts/threads/members per day over the last week.

But, the page generation times for Forums Stats is a little slow - since I'm new to PHP/SQL etc, just wondering, is there a faster method?

This is the code I'm using:
// average over past week
$lastweekdate = (time()-60*60*24*7);
$query = $db->simple_select(TABLE_PREFIX."posts", "COUNT(pid) AS tot", "dateline >= ".$lastweekdate);
$result = $db->fetch_array($query);
$postsperdaylastweek = my_number_format(round(($result['tot'] / 7), 2));
$query = $db->simple_select(TABLE_PREFIX."threads", "COUNT(tid) AS tot", "dateline >= ".$lastweekdate);
$result = $db->fetch_array($query);
$threadsperdaylastweek = my_number_format(round(($result['tot'] / 7), 2));
$query = $db->simple_select(TABLE_PREFIX."users", "COUNT(uid) AS tot", "regdate >= ".$lastweekdate);
$result = $db->fetch_array($query);
$membersperdaylastweek = my_number_format(round(($result['tot'] / 7), 2));

Page generation times aren't bad, but I'd prefer them to be quicker - can this be optimized (by simple means) any more?

Thanks a lot for any replies Smile