mirror of
https://github.com/LemmyNet/lemmy
synced 2024-11-21 20:13:05 +00:00
Exponential controversy rank (#4872)
* Update utils.sql * add migration
This commit is contained in:
parent
a7c39226e2
commit
fd58b4f809
3 changed files with 35 additions and 1 deletions
|
@ -8,7 +8,7 @@ CREATE FUNCTION r.controversy_rank (upvotes numeric, downvotes numeric)
|
|||
0
|
||||
ELSE
|
||||
(
|
||||
upvotes + downvotes) * CASE WHEN upvotes > downvotes THEN
|
||||
upvotes + downvotes) ^ CASE WHEN upvotes > downvotes THEN
|
||||
downvotes::float / upvotes::float
|
||||
ELSE
|
||||
upvotes::float / downvotes::float
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
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;
|
||||
|
17
migrations/2024-07-01-014711_exponential_controversy/up.sql
Normal file
17
migrations/2024-07-01-014711_exponential_controversy/up.sql
Normal file
|
@ -0,0 +1,17 @@
|
|||
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;
|
||||
|
Loading…
Reference in a new issue