From e2b5f9276562a0bfee3b4b65fc553988c2fa18d0 Mon Sep 17 00:00:00 2001 From: Joanna Dyczka Date: Thu, 17 Oct 2024 13:44:13 +0200 Subject: [PATCH] [#2171] eliminate duplicate DReps --- CHANGELOG.md | 1 + govtool/backend/sql/list-dreps.sql | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2624443d..8f48093f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ changes. - Fix unwanted horizontal page scroll on Governance Actions page [Issue 1897](https://github.com/IntersectMBO/govtool/issues/1897) - Fix duplicate testIds for reference errors and hints in DRep metadata form [Issue 1965](https://github.com/IntersectMBO/govtool/issues/1965) +- Eliminate duplicate DReps in the DRep Directory [Issue 2171](https://github.com/IntersectMBO/govtool/issues/2171) ### Changed diff --git a/govtool/backend/sql/list-dreps.sql b/govtool/backend/sql/list-dreps.sql index 2ae88d72..f8c556ff 100644 --- a/govtool/backend/sql/list-dreps.sql +++ b/govtool/backend/sql/list-dreps.sql @@ -30,7 +30,7 @@ SELECT newestRegister.time AS last_register_time, COALESCE(latestDeposit.deposit, 0), non_deregister_voting_anchor.url IS NOT NULL AS has_non_deregister_voting_anchor, - off_chain_vote_fetch_error.fetch_error, + fetch_error.message, off_chain_vote_drep_data.payment_address, off_chain_vote_drep_data.given_name, off_chain_vote_drep_data.objectives, @@ -96,8 +96,15 @@ FROM LEFT JOIN DRepDistr ON DRepDistr.hash_id = dh.id AND DRepDistr.rn = 1 LEFT JOIN voting_anchor va ON va.id = dr_voting_anchor.voting_anchor_id - LEFT JOIN voting_anchor non_deregister_voting_anchor on non_deregister_voting_anchor.id = dr_non_deregister_voting_anchor.voting_anchor_id - LEFT JOIN off_chain_vote_fetch_error ON off_chain_vote_fetch_error.voting_anchor_id = va.id + LEFT JOIN voting_anchor non_deregister_voting_anchor ON non_deregister_voting_anchor.id = dr_non_deregister_voting_anchor.voting_anchor_id + LEFT JOIN ( + SELECT fetch_error as message, voting_anchor_id + FROM off_chain_vote_fetch_error + WHERE fetch_time = ( + SELECT max(fetch_time) + FROM off_chain_vote_fetch_error) + GROUP BY fetch_error, voting_anchor_id + ) AS fetch_error ON fetch_error.voting_anchor_id = va.id LEFT JOIN off_chain_vote_data ON off_chain_vote_data.voting_anchor_id = va.id LEFT JOIN off_chain_vote_drep_data on off_chain_vote_drep_data.off_chain_vote_data_id = off_chain_vote_data.id CROSS JOIN DRepActivity @@ -140,7 +147,7 @@ GROUP BY newestRegister.time, latestDeposit.deposit, non_deregister_voting_anchor.url, - off_chain_vote_fetch_error.fetch_error, + fetch_error.message, off_chain_vote_drep_data.payment_address, off_chain_vote_drep_data.given_name, off_chain_vote_drep_data.objectives,