lemmy/migrations/2024-07-01-014711_exponential_controversy/up.sql

15 lines
368 B
MySQL
Raw Normal View History

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;