2018-11-10 13:22:14 +00:00
|
|
|
SELECT q.site, q.question, q.hotness,
|
2018-11-10 12:45:48 +00:00
|
|
|
(LEAST(COUNT(a.*), 10) * (q.up_votes - q.down_votes) / 5.0 + SUM(a.up_votes - a.down_votes)) /
|
|
|
|
(GREATEST(DATE_PART('day', q.timestamp - qq.createddate) * 24 +
|
2018-11-10 12:53:27 +00:00
|
|
|
DATE_PART('hour', q.timestamp - qq.createddate) + 1, 6) ^ 1.4) *
|
2018-11-10 13:22:14 +00:00
|
|
|
CASE q.site WHEN 'workplace' THEN 0.55 WHEN 'softwareengineering' THEN 0.55 WHEN 'stackoverflow' THEN 0.2 ELSE 1 END
|
2018-11-10 12:53:27 +00:00
|
|
|
AS calculated_hotness,
|
|
|
|
q.hotness / (
|
|
|
|
(LEAST(COUNT(a.*), 10) * (q.up_votes - q.down_votes) / 5.0 + SUM(a.up_votes - a.down_votes)) /
|
|
|
|
(GREATEST(DATE_PART('day', q.timestamp - qq.createddate) * 24 +
|
|
|
|
DATE_PART('hour', q.timestamp - qq.createddate) + 1, 6) ^ 1.4) *
|
2018-11-10 13:22:14 +00:00
|
|
|
CASE q.site WHEN 'workplace' THEN 0.55 WHEN 'softwareengineering' THEN 0.55 WHEN 'stackoverflow' THEN 0.2 ELSE 1 END)
|
2018-11-10 12:53:27 +00:00
|
|
|
AS calculated_traffic_factor,
|
2018-11-10 12:45:48 +00:00
|
|
|
|
2018-11-10 12:53:27 +00:00
|
|
|
q.views, s.visits AS traffic
|
2018-11-10 12:45:48 +00:00
|
|
|
FROM snapshots AS q INNER JOIN questions AS qq
|
|
|
|
ON q.site = qq.site AND q.question = qq.id
|
|
|
|
INNER JOIN sites AS s ON q.site = s.name
|
|
|
|
INNER JOIN snapshots_answers AS a
|
|
|
|
ON q.site = a.site AND q.question = a.question AND q.timestamp = a.timestamp
|
2018-11-10 12:53:27 +00:00
|
|
|
WHERE q.timestamp = '2018-11-08 23:45'
|
2018-11-10 12:45:48 +00:00
|
|
|
GROUP BY q.site, q.question, q.timestamp, qq.createddate, s.visits
|
2018-11-10 12:53:27 +00:00
|
|
|
ORDER BY q.hotness DESC
|