From 56a5b05fbed4e723cf5b28f0f0cc30165f9da74a Mon Sep 17 00:00:00 2001 From: Ying Date: Thu, 24 Oct 2024 12:00:49 -0700 Subject: [PATCH] remove null address from delegator count (#563) --- .../down.sql | 1 + .../up.sql | 9 +++++++++ 2 files changed, 10 insertions(+) create mode 100644 rust/processor/src/db/postgres/migrations/2024-10-23-232703_num_active_delegator_per_pool/down.sql create mode 100644 rust/processor/src/db/postgres/migrations/2024-10-23-232703_num_active_delegator_per_pool/up.sql diff --git a/rust/processor/src/db/postgres/migrations/2024-10-23-232703_num_active_delegator_per_pool/down.sql b/rust/processor/src/db/postgres/migrations/2024-10-23-232703_num_active_delegator_per_pool/down.sql new file mode 100644 index 000000000..92e6e3639 --- /dev/null +++ b/rust/processor/src/db/postgres/migrations/2024-10-23-232703_num_active_delegator_per_pool/down.sql @@ -0,0 +1 @@ +DROP VIEW IF EXISTS num_active_delegator_per_pool; diff --git a/rust/processor/src/db/postgres/migrations/2024-10-23-232703_num_active_delegator_per_pool/up.sql b/rust/processor/src/db/postgres/migrations/2024-10-23-232703_num_active_delegator_per_pool/up.sql new file mode 100644 index 000000000..3f572c106 --- /dev/null +++ b/rust/processor/src/db/postgres/migrations/2024-10-23-232703_num_active_delegator_per_pool/up.sql @@ -0,0 +1,9 @@ +-- need this for delegation staking +CREATE OR REPLACE VIEW num_active_delegator_per_pool AS +SELECT pool_address, + COUNT(DISTINCT delegator_address) AS num_active_delegator +FROM current_delegator_balances +WHERE shares > 0 + AND delegator_address != '0x0000000000000000000000000000000000000000000000000000000000000000' + AND pool_type = 'active_shares' +GROUP BY 1;