Query editor
WITH active_fids AS (SELECTfid,COUNT(DISTINCT DATE_TRUNC('day', timestamp)) AS distinct_cast_daysFROM dune.neynar.dataset_farcaster_castsWHERE timestamp >= current_date - INTERVAL '{{previous_days}}' DAYAND timestamp < current_dateGROUP BY fidHAVING COUNT(DISTINCT DATE_TRUNC('day', timestamp)) >= {{times_casted}} -- At least 5 distinct days with casts),follower_counts AS (SELECTl.target_fid,COUNT(l.fid) AS total_followers,COUNT(CASE WHEN spam.label_value = 0 AND af.fid IS NOT NULL THEN l.fid END) AS L0,COUNT(CASE WHEN spam.label_value = 1 AND af.fid IS NOT NULL THEN l.fid END) AS L1,COUNT(CASE WHEN spam.label_value IN (NULL, 1, 2) AND af.fid IS NOT NULL THEN l.fid END) AS L1_L2_null,COUNT(CASE WHEN spam.label_value = 2 AND af.fid IS NOT NULL THEN l.fid END) AS L2FROMdune.neynar.dataset_farcaster_links AS lLEFT JOINquery_5133945 AS spamON spam.fid = l.fidJOIN active_fids af -- Only count followers who are active castersON l.fid = af.fidWHEREl.deleted_at IS NULLGROUP BYl.target_fid)SELECTfc.target_fid AS fid,get_href(CONCAT('https://warpcast.com/', f.fname), f.fname) AS fname,fc.total_followers,fc.L1_L2_null,ROUND((fc.L1_L2_null * 100.0) / NULLIF(fc.total_followers, 0), 2) AS L1_L2_null_percFROM follower_counts fcJOIN dune.neynar.dataset_farcaster_profile_with_addresses fON fc.target_fid = f.fidWHERE fc.total_followers > 10ORDER BY fc.total_followers DESC;