Skip to content
Snippets Groups Projects
Commit 8a1d8c5b authored by Michal Zander's avatar Michal Zander
Browse files

Fix rank view

account_reputations table should be left joined with hive_accounts, accounts with reputation 0 does not exist in account_reputation table
parent 39797ab3
No related branches found
No related tags found
1 merge request!854Fix score
...@@ -16,16 +16,14 @@ LEFT JOIN ...@@ -16,16 +16,14 @@ LEFT JOIN
( (
WITH base_rank_data AS WITH base_rank_data AS
( (
SELECT ha3.account_id, rank() OVER (ORDER BY ha3.reputation DESC) AS account_rank SELECT ha.id, COALESCE(ha3.reputation,0) as reputation
FROM account_reputations ha3 FROM hivemind_app.hive_accounts ha
ORDER BY ha3.reputation DESC LEFT JOIN account_reputations ha3 ON ha.haf_id = ha3.account_id
LIMIT 150000
) )
SELECT ha.id, SELECT brd.id, rank() OVER (ORDER BY brd.reputation DESC) AS account_rank
brd.account_rank
FROM base_rank_data brd FROM base_rank_data brd
JOIN hivemind_app.hive_accounts ha on ha.haf_id = brd.account_id ORDER BY brd.reputation DESC
LIMIT 150000
-- Conditions above (related to rank.position) eliminates all records having rank > 100k. So with inclding some -- Conditions above (related to rank.position) eliminates all records having rank > 100k. So with inclding some
-- additional space for redundant accounts (having same reputation) lets assume we're limiting it to 150k -- additional space for redundant accounts (having same reputation) lets assume we're limiting it to 150k
-- As another reason, it can be pointed that only 2% of account has the same reputations, it means only 2000 -- As another reason, it can be pointed that only 2% of account has the same reputations, it means only 2000
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment