Skip to content

Commit d506c8a

Browse files
committed
Switch from SQRT to POWER for sqlite support
1 parent 4345ba4 commit d506c8a

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

factory/ideas.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,9 @@ protected function query_sort($sort, $direction)
134134
else
135135
{
136136
// https://www.evanmiller.org/how-not-to-sort-by-average-rating.html
137+
// switched SQRT(x) to POWER(x, 0.5) for SQLITE3 support
137138
$this->sql['SELECT'][] = '((i.idea_votes_up + 1.9208) / (i.idea_votes_up + i.idea_votes_down) -
138-
1.96 * SQRT((i.idea_votes_up * i.idea_votes_down) / (i.idea_votes_up + i.idea_votes_down) + 0.9604) /
139+
1.96 * POWER((i.idea_votes_up * i.idea_votes_down) / (i.idea_votes_up + i.idea_votes_down) + 0.9604, 0.5) /
139140
(i.idea_votes_up + i.idea_votes_down)) / (1 + 3.8416 / (i.idea_votes_up + i.idea_votes_down))
140141
AS ci_lower_bound';
141142

0 commit comments

Comments
 (0)