Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Some modifications in db/hotness.php

+3 votes
asked Sep 3 in Q2A Core by esqeudero

In db/hotness.php there is a following code:

$query= "UPDATE ^posts AS x, (SELECT parents.postid, parents.created AS qcreated, COALESCE(MAX(children.created), parents.created) as acreated, COUNT(children.postid) AS acount, parents.netvotes, parents.views FROM ^posts AS parents LEFT JOIN ^posts AS children ON parents.postid=children.parentid AND children.type='A' WHERE parents.postid>=# AND parents.postid<=# AND LEFT(parents.type, 1)='Q' GROUP BY postid) AS a SET x.hotness=(".

'((TO_DAYS(a.qcreated)-734138)*86400.0+TIME_TO_SEC(a.qcreated))*# + '. // zero-point is Jan 1, 2010

'((TO_DAYS(a.acreated)-734138)*86400.0+TIME_TO_SEC(a.acreated))*# + '.

'(a.acount+0.0)*# + '.

'(a.netvotes+0.0)*# + '.


')'.($viewincrement ? ', x.views=x.views+1, x.lastviewip=INET_ATON($)' : '').' 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








$viewincrement ? 1 : 0,



The zero point date is set as Jan 1, 2010. I created my website on august 2017, so it would be better for me to set the zero-point at 01.08.2017. For that I will change 734138 into 736205. Is it true?

And suppose that I change the zero-point then, how should I set "qa_opt('hot_weight_answers')*160000", "qa_opt('hot_weight_votes')*160000", and "qa_opt('hot_weight_views')*4000" ?

What are these values 160000 and 4000? I guess they are set in order to make all factors influence equal. If so, and if I change my zero-point how I should set these values for maintain equal influence? 

Please make me clear if you have better understanding on this topic?

NOT: I want to change my zero-point in order to get rid of long hotness numbers in db. Currently, my hotness number is formed of 11 digits. For example, it is my one of posts hotness number: 42362600000

It shows that I can get rid of five zeros at the end.

Q2A version: 1.7.4 fairly modified and customized
commented Sep 3 by Scott
Why do you want to "get rid of long hotness numbers"?
commented Sep 4 by esqeudero
because it is pointless to have 5 zeros at the end, I examined all my posts hotness numbers and all have 5 zeros at the end.
More importantly, by the time, for examle after 5 years, how the hotness number will look like?  A year equals to 3.154e+7 seconds, just imagine.

2 Answers

+1 vote
answered Sep 4 by Scott

The hotness field is a float which stores values up to 3.402823466E+38, or 340282346600000000000000000000000000000. So there is no problem with the number being large, you will never break the limit. I have a popular Q&A site that's been running for more than 5 years now and the largest hotness value is 106711000000.

You asked about the weighting values - there's a comment above those in the code that explain. They are based on analysis of this site. For example the answers factor has a weight 40x bigger than views because according to the analysis, questions on here have around 40x more views than answers (on average).

You can make changes to the weights by setting the options at the bottom of Admin > Lists. You don't need to change core code for that.

commented Sep 5 by esqeudero
Thanks Scott, your explanation is helpful.  As I can see the gap between foundation of your website and the zero-point (2010) is smaller. So, you dont have other option. However, in my case, I case 7 years gap. I know this wont be a problem from the database end, but still it will be a good idea to shrink this gap in the beginning as I just established my website.
Thank you again for your clarification.
commented Sep 5 by Scott
There is really really NO problem with the hotness numbers having extra zeroes. You should focus on doing something more productive.
+1 vote
answered Sep 5 by esqeudero

Dear friends,

I managed to modify this by myself. Here is guide how to do it, maybe some of you also interested to do it as well.

In order to get rid of long hotness number, do followings.

1) Determine your zero-point. Zero-point should be a date very close but before the date of q2a installation. For example, if you install q2a on 18th of august 2017, it will be a good idea to set zero-point as 1st august 2017.

2) Convert you zero-point into DAYS via MSQL TO_DAYS() function at https://www.w3schools.com/sql/trymysql.asp?filename=trysql_func_mysql_to_days2

3) Open db/hotness.php and find function qa_db_hotness_update($firstpostid, $lastpostid=null, $viewincrement=false)

4) change 734138 in below to two lines with your zero-point number calculated in step2:

(TO_DAYS(a.qcreated)-734138 )*86400.0+TIME_TO_SEC(a.qcreated)

(TO_DAYS(a.acreated)-734138 )*86400.0+TIME_TO_SEC(a.acreated)

5) Also change the  $arguement array with below:








$viewincrement ? 1 : 0,



Here as you can see I simple divided all factors by 100. 

6) Set influence of factors in admin/list, make sure your set values between 1-100. Because I already divided factors with 100 in step 5.

This work me perfect. Here is my output.Left is before process, right is after process. (Hotness number)

42392600000 5253520
42363300000 4959960
42292000000 4247540
42256100000 3888520
42221100000 3537940