Query editor
withproposals as (SELECTcontract_address,count(distinct bytearray_substring(data,1+32+12,20)) as num_proposalsFROM optimism.logsWHERE topic0 = 0x7585f467599d0f008985f231af99293be388626ac16ca59505c2f8f88969cd63and block_time > timestamp '2024-1-10 00:00:00'group by 1), has_votes as (SELECTcontract_address,count(*) as votesFROM optimism.logsWHERE topic0 = 0x2c9deb38f462962eadbd85a9d3a4120503ee091f1582eaaa10aa8c6797651d29and block_time > timestamp '2024-1-10 00:00:00'group by 1having count(*) > 0)SELECTl.block_time as created_at-- convert UTC to EST, then check for 7 and 14 days after week of quest start (i.e. monday of that week),case when date_trunc('week',l.block_time) + interval '28' day <= date_trunc('week',now() - interval '5' hour)then '🔒 CLOSED'when date_trunc('week',l.block_time) + interval '14' day <= date_trunc('week',now() - interval '5' hour)then '🔮 VOTING'else '✅ OPEN' end as quest_status,get_href('https://jokerace.io/contest/optimism/' || cast(l.contract_address as varchar), lower(from_utf8(bytearray_substring(l.data,1+288+32,cast(bytearray_to_uint256(bytearray_substring(l.data,1+288,32)) as bigint)))))as name, case when l.contract_address IN (--m1-op mission quests. turn this into a values table after second mission launches.0x8b720e12e520d2b448e6b4c0fad55b8e08b64761,0x1c5dde828c9fc635e833eeba418278a264cc1a15,0x6e8601c0e57873139f1da5524eff876f93b22b6e)then 2else 1end as guild_token_id, from_utf8(bytearray_substring(l.data,1+224+32,cast(bytearray_to_uint256(bytearray_substring(l.data,1+224,32)) as bigint))) as version, p.num_proposals, l.contract_address as quest_contract_addressFROM optimism.logs lLEFT JOIN proposals p ON l.contract_address = p.contract_addressLEFT JOIN has_votes v ON l.contract_address = v.contract_addressWHERE l.topic0 = 0x9a9bca21e4e51607db64fbdbcd7b2284a909c6a8969821f0d161efbdcae70160and l.contract_address not IN (0xa2a4be4486bf8efa7b6e1c341852cf2d0cfa09cd) --failed deploymentand bytearray_substring(l.data,1+32+32+32+12,20) = 0x4d6e6ef749d2c0e3ee89fc788a00e28db71aa6b5 --cryptodatabytes.ethand l.block_time > timestamp '2024-1-10 00:00:00'and (lower(from_utf8(bytearray_substring(l.data,1+288+32,cast(bytearray_to_uint256(bytearray_substring(l.data,1+288,32)) as bigint)))) LIKE '%your best%work%'OR l.contract_address IN (--M1-OP checkpoints0x8b720e12e520d2b448e6b4c0fad55b8e08b64761 --small, 0x1c5dde828c9fc635e833eeba418278a264cc1a15 --medium, 0x6e8601c0e57873139f1da5524eff876f93b22b6e --large