SandeshCopy of Untitled Query
Updated 2023-05-25
99
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
›
⌄
with t as
(
select
block_timestamp,
tx_hash,
RECEIVER_ID as dao,
ACTIONS:"predecessor_id" as voter,
parse_json(ACTIONS:"receipt":"Action":"actions")[0]:"FunctionCall":"method_name" as act,
parse_json(try_base64_decode_string(parse_json(ACTIONS:"receipt":"Action":"actions")[0]:"FunctionCall":"args")):"id" as proposal_id,
parse_json(try_base64_decode_string(parse_json(ACTIONS:"receipt":"Action":"actions")[0]:"FunctionCall":"args")):"action" as vote,
'-' as proposer
from near.core.fact_receipts
where 1=1
-- and tx_hash = 'ChSLk25Qh7YeWEgTwHFuqhZek334zWLF12SRybGeFYXX'
and RECEIVER_ID='marketing.sputnik-dao.near'
and act='act_proposal'
),
t2 as
(
select
PROPOSAL_ID,
-- count_if(VOTE='VoteApprove') over (partition by PROPOSAL_ID) as cnt,
-- count_if(VOTE!='VoteApprove') over (partition by PROPOSAL_ID) as acnt,
case
when count_if(VOTE='VoteApprove') over (partition by PROPOSAL_ID) + count_if(VOTE!='VoteApprove') over (partition by PROPOSAL_ID) < 3 then 'Expired'
when count_if(VOTE='VoteApprove') over (partition by PROPOSAL_ID) > count_if(VOTE!='VoteApprove') over (partition by PROPOSAL_ID) then 'Approved'
when count_if(VOTE='VoteApprove') over (partition by PROPOSAL_ID) < count_if(VOTE!='VoteApprove') over (partition by PROPOSAL_ID) then 'Rejected'
else 'Expired'
end as outcome
from t
),
t3 as
(
select distinct PROPOSAL_ID, (outcome) from t2
),
Run a query to Download Data