Skip to content

Commit

Permalink
Latest schema with change to scoring
Browse files Browse the repository at this point in the history
  • Loading branch information
dthyresson committed Mar 30, 2022
1 parent 4916859 commit 259b3c6
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions data/db/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -491,25 +491,25 @@ SELECT
CASE WHEN direction = 'UP' THEN
1
WHEN direction = 'DOWN' THEN
- 1
-1
ELSE
0
END), 0) "voteDelta",
sum(
round(coalesce((sum(
CASE WHEN direction = 'UP' THEN
1
WHEN direction = 'DOWN' THEN
- 1
-1
ELSE
0
END) - 1 / (DATE_PART('hour', now() - max("Vote"."createdAt")) + 2) ^ 1.8 AS "score",
rank() OVER (ORDER BY coalesce(sum( CASE WHEN direction = 'UP' THEN
END ) - 1) / (DATE_PART('hour', now() - max("Vote"."createdAt")) + 2) ^ 1.8 * 100000, -2147483648)::numeric, 0) AS "score",
rank() OVER (ORDER BY round(coalesce((sum( CASE WHEN direction = 'UP' THEN
1
WHEN direction = 'DOWN' THEN
- 1
-1
ELSE
0
END) - 1 / (DATE_PART('hour', now() - max("Vote"."createdAt")) + 2) ^ 1.8, '-infinity')
END) - 1) / (DATE_PART('hour', now() - max("Vote"."createdAt")) + 2) ^ 1.8 * 100000, -2147483648)::numeric, 0)
DESC,
"Post"."createdAt" DESC,
"Post".title ASC) "voteRank"
Expand Down Expand Up @@ -1331,6 +1331,8 @@ CREATE TABLE auth.users (
email_change_token_current character varying(255) DEFAULT ''::character varying,
email_change_confirm_status smallint DEFAULT 0,
banned_until timestamp with time zone,
reauthentication_token character varying(255) DEFAULT ''::character varying,
reauthentication_sent_at timestamp with time zone,
CONSTRAINT users_email_change_confirm_status_check CHECK (((email_change_confirm_status >= 0) AND (email_change_confirm_status <= 2)))
);

Expand Down Expand Up @@ -1427,7 +1429,7 @@ CREATE TABLE public."Post" (
"downVoteTotal" integer DEFAULT 0 NOT NULL,
"voteTotal" integer DEFAULT 0 NOT NULL,
"voteRank" integer DEFAULT 1 NOT NULL,
score real DEFAULT '0'::real,
score integer DEFAULT 0,
"voteDelta" integer DEFAULT 0 NOT NULL,
CONSTRAINT post_title_length CHECK ((char_length(title) > 0)),
CONSTRAINT post_url_length CHECK ((char_length(url) > 0))
Expand Down

1 comment on commit 259b3c6

@vercel
Copy link

@vercel vercel bot commented on 259b3c6 Mar 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.