lemmy/migrations/2024-07-01-014711_exponential_controversy/up.sql
dullbananas da9582c80a
Optimize migrations (#5301)
* Optimize migrations

* update smoosh migration

---------

Co-authored-by: Dessalines <tyhou13@gmx.com>
2025-01-13 23:10:31 -05:00

14 lines
368 B
SQL

UPDATE
post_aggregates
SET
controversy_rank = (upvotes + downvotes) ^ CASE WHEN upvotes > downvotes THEN
downvotes::float / upvotes::float
ELSE
upvotes::float / downvotes::float
END
WHERE
upvotes > 0
AND downvotes > 0
-- a number divided by itself is 1, and `* 1` does the same thing as `^ 1`
AND upvotes != downvotes;