Commit 80e7ee23 by Scott

Only recalculate hotness when necessary

parent 694c2eaf
...@@ -374,8 +374,9 @@ function qa_do_content_stats($qa_content) ...@@ -374,8 +374,9 @@ function qa_do_content_stats($qa_content)
require_once QA_INCLUDE_DIR . 'db/hotness.php'; require_once QA_INCLUDE_DIR . 'db/hotness.php';
qa_db_increment_views($qa_content['inc_views_postid']); $viewsIncremented = qa_db_increment_views($qa_content['inc_views_postid']);
if (qa_opt('recalc_hotness_q_view')) {
if ($viewsIncremented && qa_opt('recalc_hotness_q_view')) {
qa_db_hotness_update($qa_content['inc_views_postid']); 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 ...@@ -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). * Increment the views counter for the post (if different IP from last view).
* @param int $postid The ID of the post * @param int $postid The ID of the post
* @return void * @return bool Whether views were actually incremented.
*/ */
function qa_db_increment_views($postid) function qa_db_increment_views($postid)
{ {
...@@ -36,6 +36,8 @@ function qa_db_increment_views($postid) ...@@ -36,6 +36,8 @@ function qa_db_increment_views($postid)
$ipHex = bin2hex(@inet_pton(qa_remote_ip_address())); $ipHex = bin2hex(@inet_pton(qa_remote_ip_address()));
qa_db_query_sub($query, $ipHex, $postid, $ipHex); 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