You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WHEN (safe_json_parse(REPLACE(rap.action_logs[1], 'EVENT_JSON:', '')) ->>'error') IS NULL
111
+
THEN (safe_json_parse(REPLACE(rap.action_logs[1], 'EVENT_JSON:', '')) ->'data'->0->>'account_id')
112
+
ELSE NULL
113
+
END,
114
+
rap.signer_account_id
115
+
) AS registered_voter_id
116
+
, CASE
117
+
WHEN (safe_json_parse(REPLACE(rap.action_logs[1], 'EVENT_JSON:', '')) ->>'error') IS NULL
118
+
THEN ((safe_json_parse(REPLACE(rap.action_logs[1], 'EVENT_JSON:', '')) ->'data'->0->>'locked_near_balance'))::NUMERIC
119
+
ELSE NULL
120
+
END AS voting_power_from_locks_unlocks
121
+
, CASE
122
+
WHEN (safe_json_parse(REPLACE(rap.action_logs[1], 'EVENT_JSON:', '')) ->>'error') IS NULL
123
+
THEN ((safe_json_parse(REPLACE(rap.action_logs[1], 'EVENT_JSON:', '')) ->'data'->0->>'timestamp'))::NUMERIC
124
+
ELSE NULL
125
+
END AS lockup_update_at_ns
119
126
FROM receipt_actions_prep AS rap
120
127
WHERE
121
128
rap.method_name='on_lockup_update'
122
129
ORDER BY
123
-
rap.signer_account_id,-- DISTINCT ON key
124
-
rap.block_timestampDESC, -- "latest" first
125
-
rap.receipt_idDESC-- deterministic tie-breaker
130
+
rap.signer_account_id-- DISTINCT ON key
131
+
, rap.block_timestampDESC-- "latest" first
132
+
, rap.receipt_idDESC-- deterministic tie-breaker
126
133
)
127
134
/* Sourcing Registered Voters from Deploy Lockup Event (Excluding dupes due to account already being registered) */
128
135
--Whenever a user registers to vote, there should always be a non-null storage deposit, aka, initial voting power amount.
129
-
--Inner join excludes scenarios where a vote registration action (aka deploy_lockup for a given user) is duped bc the user's account was already registered and the subsequent storage_deposit event tracks a null initial_voting_power amount.
136
+
--is_remove_dupe flag excludes scenarios where a vote registration action (aka deploy_lockup for a given user) is duped bc the user's account was already registered and the subsequent storage_deposit event tracks a null initial_voting_power amount.
137
+
--NOTE: When a user leverages the web app to register to vote, the storage_deposit and deploy_lockup event for their account_id will share the same receipt_id.
138
+
------- When a user leverages the NEAR CLI to register to vote, the receipt_ids for these events are different (rare scenario).
0 commit comments