lemmy/migrations/2024-07-01-014711_exponential_controversy/up.sql
dullbananas fd58b4f809
Exponential controversy rank (#4872)
* Update utils.sql

* add migration
2024-07-02 09:40:18 -04:00

18 lines
365 B
SQL

UPDATE
post_aggregates
SET
controversy_rank = CASE WHEN downvotes <= 0
OR upvotes <= 0 THEN
0
ELSE
(upvotes + downvotes) ^ CASE WHEN upvotes > downvotes THEN
downvotes::float / upvotes::float
ELSE
upvotes::float / downvotes::float
END
END
WHERE
upvotes > 0
AND downvotes > 0;