mirror of
https://github.com/LemmyNet/lemmy.git
synced 2025-01-15 22:45:56 +00:00
da9582c80a
* Optimize migrations * update smoosh migration --------- Co-authored-by: Dessalines <tyhou13@gmx.com>
14 lines
368 B
SQL
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;
|
|
|