Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
outils
question2answer
Commits
788f260c
Commit
788f260c
authored
7 years ago
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split views increment out of hotness function
parent
d46809f4
dev
…
3113-openbar-authentification
3241-delete-all-the-question
3242-password-removed
3414-no-change-mail
3414-stop-mail-send
main
v1.8.6
v1.8.5
v1.8.4
v1.8.3
v1.8.2
v1.8.1
v1.8.0
v1.8.0-beta2
v1.8.0-beta1
No related merge requests found
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
10 deletions
+22
-10
page.php
qa-include/app/page.php
+6
-1
hotness.php
qa-include/db/hotness.php
+16
-9
No files found.
qa-include/app/page.php
View file @
788f260c
...
...
@@ -370,7 +370,12 @@ function qa_do_content_stats($qa_content)
{
if
(
isset
(
$qa_content
[
'inc_views_postid'
]))
{
require_once
QA_INCLUDE_DIR
.
'db/hotness.php'
;
qa_db_hotness_update
(
$qa_content
[
'inc_views_postid'
],
null
,
true
);
qa_db_increment_views
(
$qa_content
[
'inc_views_postid'
]);
if
(
qa_opt
(
'recalc_hotness_q_view'
))
{
qa_db_hotness_update
(
$qa_content
[
'inc_views_postid'
]);
}
return
true
;
}
...
...
This diff is collapsed.
Click to expand it.
qa-include/db/hotness.php
View file @
788f260c
...
...
@@ -26,6 +26,20 @@ 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
*/
function
qa_db_increment_views
(
$postid
)
{
$query
=
'UPDATE ^posts SET views=views+1, lastviewip=UNHEX($) WHERE postid=# AND (lastviewip IS NULL OR lastviewip!=UNHEX($))'
;
$ipHex
=
bin2hex
(
@
inet_pton
(
qa_remote_ip_address
()));
qa_db_query_sub
(
$query
,
$ipHex
,
$postid
,
$ipHex
);
}
/**
* Recalculate the hotness in the database for posts $firstpostid to $lastpostid (if specified)
* If $viewincrement is true, also increment the views counter for the post (if different IP from last view),
* and include that in the hotness calculation
...
...
@@ -47,9 +61,8 @@ function qa_db_hotness_update($firstpostid, $lastpostid = null, $viewincrement =
'((TO_DAYS(a.acreated)-734138)*86400.0+TIME_TO_SEC(a.acreated))*# + '
.
'(a.acount+0.0)*# + '
.
'(a.netvotes+0.0)*# + '
.
'(a.views+0.0+#)*#'
.
')'
.
(
$viewincrement
?
', x.views=x.views+1, x.lastviewip=UNHEX($)'
:
''
)
.
' WHERE x.postid=a.postid'
.
(
$viewincrement
?
' AND (x.lastviewip IS NULL OR x.lastviewip!=UNHEX($))'
:
''
);
'(a.views+0.0)*#'
.
') WHERE x.postid=a.postid'
;
// Additional multiples based on empirical analysis of activity on Q2A meta site to give approx equal influence for all factors
...
...
@@ -60,15 +73,9 @@ function qa_db_hotness_update($firstpostid, $lastpostid = null, $viewincrement =
qa_opt
(
'hot_weight_a_age'
),
qa_opt
(
'hot_weight_answers'
)
*
160000
,
qa_opt
(
'hot_weight_votes'
)
*
160000
,
$viewincrement
?
1
:
0
,
qa_opt
(
'hot_weight_views'
)
*
4000
,
);
if
(
$viewincrement
)
{
$ipHex
=
bin2hex
(
@
inet_pton
(
qa_remote_ip_address
()));
array_push
(
$arguments
,
$ipHex
,
$ipHex
);
}
qa_db_query_raw
(
qa_db_apply_sub
(
$query
,
$arguments
));
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment