Skip to content

Commit 8d9feaf

Browse files
committed
Tweak scoring algo
1 parent e2840ec commit 8d9feaf

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

data/supabase/06-update-post-vote-counts.sql

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ SELECT
1212
CASE WHEN direction = 'UP' THEN
1313
1
1414
WHEN direction = 'DOWN' THEN
15-
- 1
15+
-1
1616
ELSE
1717
0
1818
END), 0) "voteDelta",
19-
round(coalesce(sum(
19+
round(coalesce((sum(
2020
CASE WHEN direction = 'UP' THEN
2121
1
2222
WHEN direction = 'DOWN' THEN
23-
- 1
23+
-1
2424
ELSE
2525
0
26-
END) - 1 / (DATE_PART('hour', now() - max("Vote"."createdAt")) + 2) ^ 1.8 * 100000, -2147483648)::numeric, 0) AS "score",
27-
rank() OVER (ORDER BY round(coalesce(sum( CASE WHEN direction = 'UP' THEN
26+
END ) - 1) / (DATE_PART('hour', now() - max("Vote"."createdAt")) + 2) ^ 1.8 * 100000, -2147483648)::numeric, 0) AS "score",
27+
rank() OVER (ORDER BY round(coalesce((sum( CASE WHEN direction = 'UP' THEN
2828
1
2929
WHEN direction = 'DOWN' THEN
30-
- 1
30+
-1
3131
ELSE
3232
0
33-
END) - 1 / (DATE_PART('hour', now() - max("Vote"."createdAt")) + 2) ^ 1.8 * 100000, -2147483648)::numeric, 0)
33+
END) - 1) / (DATE_PART('hour', now() - max("Vote"."createdAt")) + 2) ^ 1.8 * 100000, -2147483648)::numeric, 0)
3434
DESC,
3535
"Post"."createdAt" DESC,
3636
"Post".title ASC) "voteRank"

0 commit comments

Comments
 (0)