Commit 80e7ee23 by Scott

Only recalculate hotness when necessary

parent 694c2eaf
......@@ -374,8 +374,9 @@ function qa_do_content_stats($qa_content)
require_once QA_INCLUDE_DIR . 'db/hotness.php';
qa_db_increment_views($qa_content['inc_views_postid']);
if (qa_opt('recalc_hotness_q_view')) {
$viewsIncremented = qa_db_increment_views($qa_content['inc_views_postid']);
if ($viewsIncremented && qa_opt('recalc_hotness_q_view')) {
qa_db_hotness_update($qa_content['inc_views_postid']);
}
......
......@@ -28,7 +28,7 @@ if (!defined('QA_VERSION')) { // don't allow this page to be requested directly
/**
* Increment the views counter for the post (if different IP from last view).
* @param int $postid The ID of the post
* @return void
* @return bool Whether views were actually incremented.
*/
function qa_db_increment_views($postid)
{
......@@ -36,6 +36,8 @@ function qa_db_increment_views($postid)
$ipHex = bin2hex(@inet_pton(qa_remote_ip_address()));
qa_db_query_sub($query, $ipHex, $postid, $ipHex);
return qa_db_affected_rows() > 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment