Query editor
-- This query used incompatible data types from Dune SQL alpha and may need to be updated.-- More details can be found on https://dune.com/docs/query/dunesql-changes/with date_filter as (select (casewhen '{{date_period}}' = '7 Days' then now() - interval '7' daywhen '{{date_period}}' = '30 Days' then now() - interval '30' daywhen '{{date_period}}' = '3 Months' then now() - interval '3' monthwhen '{{date_period}}' = '6 Months' then now() - interval '6' monthelse date('2022-05-18')end) as start_date),profile_filter as (select profileIdfrom (select 1 as sort,profileIdfrom lens_polygon.LensHub_evt_ProfileCreatedwhere handle = '{{profile_handle}}'union allselect 2 as sort,profileIdfrom lens_polygon.LensHub_evt_ProfileCreatedwhere handle = '{{profile_handle}}.lens'union allselect 3 as sort, uint256 '0' as profileId) torder by sortlimit 1),action_data as (with post_data as (select evt_block_time,evt_tx_hash,p.profileId,pubIdfrom lens_polygon.LensHub_evt_PostCreated pinner join date_filter d on trueinner join profile_filter f on truewhere evt_block_time > d.start_dateand (f.profileId = uint256 '0' or f.profileId = p.profileId)),comment_data as (select evt_block_time,evt_tx_hash,c.profileId,pubIdfrom lens_polygon.LensHub_evt_CommentCreated cinner join date_filter d on trueinner join profile_filter f on truewhere evt_block_time > d.start_dateand (f.profileId = uint256 '0' or f.profileId = c.profileId)),