FIX: Error when calculating geometric mean of 0 for read timings

This commit is contained in:
Robin Ward 2017-03-27 12:45:34 -04:00
parent 243b5756ee
commit 27a73c73f9
1 changed files with 1 additions and 1 deletions

View File

@ -505,7 +505,7 @@ class Post < ActiveRecord::Base
SET avg_time = (x.gmean / 1000) SET avg_time = (x.gmean / 1000)
FROM (SELECT post_timings.topic_id, FROM (SELECT post_timings.topic_id,
post_timings.post_number, post_timings.post_number,
round(exp(avg(ln(msecs)))) AS gmean round(exp(avg(CASE WHEN msecs > 0 THEN ln(msecs) ELSE 0 END))) AS gmean
FROM post_timings FROM post_timings
INNER JOIN posts AS p2 INNER JOIN posts AS p2
ON p2.post_number = post_timings.post_number ON p2.post_number = post_timings.post_number