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
fbb97ca1
Commit
fbb97ca1
authored
Mar 17, 2016
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix view count update with caching
parent
cc379da3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
6 deletions
+10
-6
hotness.php
qa-include/db/hotness.php
+8
-4
question.php
qa-include/pages/question.php
+2
-2
No files found.
qa-include/db/hotness.php
View file @
fbb97ca1
...
@@ -29,7 +29,8 @@
...
@@ -29,7 +29,8 @@
function
qa_db_hotness_update
(
$firstpostid
,
$lastpostid
=
null
,
$viewincrement
=
false
)
function
qa_db_hotness_update
(
$firstpostid
,
$lastpostid
=
null
,
$viewincrement
=
false
)
/*
/*
Recalculate the hotness in the database for posts $firstpostid to $lastpostid (if specified)
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, and include that in the hotness calculation
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
*/
*/
{
{
if
(
qa_to_override
(
__FUNCTION__
))
{
$args
=
func_get_args
();
return
qa_call_override
(
__FUNCTION__
,
$args
);
}
if
(
qa_to_override
(
__FUNCTION__
))
{
$args
=
func_get_args
();
return
qa_call_override
(
__FUNCTION__
,
$args
);
}
...
@@ -44,7 +45,8 @@
...
@@ -44,7 +45,8 @@
'(a.acount+0.0)*# + '
.
'(a.acount+0.0)*# + '
.
'(a.netvotes+0.0)*# + '
.
'(a.netvotes+0.0)*# + '
.
'(a.views+0.0+#)*#'
.
'(a.views+0.0+#)*#'
.
')'
.
(
$viewincrement
?
', x.views=x.views+1, x.lastviewip=$'
:
''
)
.
' WHERE x.postid=a.postid'
;
')'
.
(
$viewincrement
?
', x.views=x.views+1, x.lastviewip=$'
:
''
)
.
' WHERE x.postid=a.postid'
.
(
$viewincrement
?
' AND (x.lastviewip IS NULL OR x.lastviewip!=$)'
:
''
);
// Additional multiples based on empirical analysis of activity on Q2A meta site to give approx equal influence for all factors
// Additional multiples based on empirical analysis of activity on Q2A meta site to give approx equal influence for all factors
...
@@ -59,8 +61,10 @@
...
@@ -59,8 +61,10 @@
qa_opt
(
'hot_weight_views'
)
*
4000
,
qa_opt
(
'hot_weight_views'
)
*
4000
,
);
);
if
(
$viewincrement
)
if
(
$viewincrement
)
{
$arguments
[]
=@
inet_pton
(
qa_remote_ip_address
());
$ipbin
=
@
inet_pton
(
qa_remote_ip_address
());
array_push
(
$arguments
,
$ipbin
,
$ipbin
);
}
qa_db_query_raw
(
qa_db_apply_sub
(
$query
,
$arguments
));
qa_db_query_raw
(
qa_db_apply_sub
(
$query
,
$arguments
));
}
}
...
...
qa-include/pages/question.php
View file @
fbb97ca1
...
@@ -446,7 +446,8 @@
...
@@ -446,7 +446,8 @@
);
);
// Determine whether this request should be counted for page view statistics
// Determine whether this request should be counted for page view statistics.
// The lastviewip check is now in the hotness query in order to bypass caching.
if
(
if
(
qa_opt
(
'do_count_q_views'
)
&&
qa_opt
(
'do_count_q_views'
)
&&
...
@@ -454,7 +455,6 @@
...
@@ -454,7 +455,6 @@
(
!
qa_is_http_post
())
&&
(
!
qa_is_http_post
())
&&
qa_is_human_probably
()
&&
qa_is_human_probably
()
&&
(
(
!
$question
[
'views'
])
||
(
// if it has more than zero views
(
(
!
$question
[
'views'
])
||
(
// if it has more than zero views
(
(
@
inet_ntop
(
$question
[
'lastviewip'
])
!=
qa_remote_ip_address
())
||
(
!
isset
(
$question
[
'lastviewip'
]))
)
&&
// then it must be different IP from last view
(
(
@
inet_ntop
(
$question
[
'createip'
])
!=
qa_remote_ip_address
())
||
(
!
isset
(
$question
[
'createip'
]))
)
&&
// and different IP from the creator
(
(
@
inet_ntop
(
$question
[
'createip'
])
!=
qa_remote_ip_address
())
||
(
!
isset
(
$question
[
'createip'
]))
)
&&
// and different IP from the creator
(
(
$question
[
'userid'
]
!=
$userid
)
||
(
!
isset
(
$question
[
'userid'
]))
)
&&
// and different user from the creator
(
(
$question
[
'userid'
]
!=
$userid
)
||
(
!
isset
(
$question
[
'userid'
]))
)
&&
// and different user from the creator
(
(
$question
[
'cookieid'
]
!=
$cookieid
)
||
(
!
isset
(
$question
[
'cookieid'
]))
)
// and different cookieid from the creator
(
(
$question
[
'cookieid'
]
!=
$cookieid
)
||
(
!
isset
(
$question
[
'cookieid'
]))
)
// and different cookieid from the creator
...
...
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