From c544c003defaeb6cb280a7c096e1160da98ebe0d Mon Sep 17 00:00:00 2001 From: mistakia <1823355+mistakia@users.noreply.github.com> Date: Sun, 3 Mar 2024 21:45:20 -0500 Subject: [PATCH] fix: exclude burn address, limit to reps with at least 10k weight and at least one non null field --- scripts/generate-nano-reps.mjs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/generate-nano-reps.mjs b/scripts/generate-nano-reps.mjs index 3dbafbce..ebc3eaa8 100644 --- a/scripts/generate-nano-reps.mjs +++ b/scripts/generate-nano-reps.mjs @@ -49,6 +49,7 @@ const generate_nano_reps = async () => { 'accounts.account', 'accounts_meta_index.account' ) + .whereNot('representatives_meta_index.account', 'nano_1111111111111111111111111111111111111111111111111111hifc8npp') .select( 'accounts.alias', 'accounts_meta_index.weight', @@ -106,14 +107,17 @@ const generate_nano_reps = async () => { results_index[account] = merged_rep } - // Add missing representatives with sufficient voting weight (1000 Nano) + // Add missing representatives with sufficient voting weight (10,000 Nano) and at least one non-null field for (const account in db_reps_index) { if ( !results_index[account] && - db_reps_index[account].weight > 1000000000000000000000000000000000 + db_reps_index[account].weight > 10000000000000000000000000000000000 ) { - const { weight, ...db_rep_without_weight_field } = db_reps_index[account] - results_index[account] = db_rep_without_weight_field + const { weight, account: db_rep_account, ...db_rep_without_weight_field } = db_reps_index[account] + const has_non_null_field = Object.values(db_rep_without_weight_field).some(value => value !== null) + if (has_non_null_field) { + results_index[account] = { account, ...db_rep_without_weight_field } + } } }