diff --git a/db/90-views.sql b/db/90-views.sql index deb6aaa..b0d3f72 100644 --- a/db/90-views.sql +++ b/db/90-views.sql @@ -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; diff --git a/db/upgrade/v0.4-0.5.sql b/db/upgrade/v0.4-0.5.sql index d85f6d7..1fe1e52 100644 --- a/db/upgrade/v0.4-0.5.sql +++ b/db/upgrade/v0.4-0.5.sql @@ -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;