Fix regression where songs with 0 votes had $normaluservotepoints points

Also, remove now-unnecessary join with users
master
Dessa Simpson 2021-02-24 19:56:39 -07:00
parent 2a87e0408e
commit 6bc292f122
2 changed files with 8 additions and 8 deletions

View File

@ -41,6 +41,7 @@ CREATE OR REPLACE VIEW vote_score_vw AS
COALESCE(
SUM(CASE
WHEN follows.userid IS NULL AND subscriptions.userid IS NULL
AND votes.userid IS NOT NULL
THEN votepoints.normaluservotepoints
WHEN follows.userid IS NOT NULL AND subscriptions.userid IS NULL
THEN votepoints.followervotepoints
@ -50,10 +51,9 @@ CREATE OR REPLACE VIEW vote_score_vw AS
) AS votescore
FROM requests
LEFT JOIN votes ON votes.requesturl = requests.url
LEFT JOIN users on votes.userid = users.userid
LEFT JOIN bans ON users.userid = bans.userid
LEFT JOIN follows ON users.userid = follows.userid
LEFT JOIN subscriptions ON users.userid = subscriptions.userid
LEFT JOIN bans ON votes.userid = bans.userid
LEFT JOIN follows ON votes.userid = follows.userid
LEFT JOIN subscriptions ON votes.userid = subscriptions.userid
CROSS JOIN votepoints
WHERE bans.userid IS NULL
GROUP BY url;

View File

@ -27,6 +27,7 @@ CREATE OR REPLACE VIEW vote_score_vw AS
COALESCE(
SUM(CASE
WHEN follows.userid IS NULL AND subscriptions.userid IS NULL
AND votes.userid IS NOT NULL
THEN votepoints.normaluservotepoints
WHEN follows.userid IS NOT NULL AND subscriptions.userid IS NULL
THEN votepoints.followervotepoints
@ -36,10 +37,9 @@ CREATE OR REPLACE VIEW vote_score_vw AS
) AS votescore
FROM requests
LEFT JOIN votes ON votes.requesturl = requests.url
LEFT JOIN users on votes.userid = users.userid
LEFT JOIN bans ON users.userid = bans.userid
LEFT JOIN follows ON users.userid = follows.userid
LEFT JOIN subscriptions ON users.userid = subscriptions.userid
LEFT JOIN bans ON votes.userid = bans.userid
LEFT JOIN follows ON votes.userid = follows.userid
LEFT JOIN subscriptions ON votes.userid = subscriptions.userid
CROSS JOIN votepoints
WHERE bans.userid IS NULL
GROUP BY url;