Query editor
WITHlatest_growth AS (SELECT MAX(run_id) AS rid FROM dune.w3io.dealsync_growth),raw AS (SELECTdate AS block_date,new_users,new_deals AS raw_insights,CAST(AVG(CAST(new_deals AS DOUBLE)) OVER (ORDER BY date ROWS BETWEEN 7 PRECEDING AND 1 PRECEDING) AS BIGINT) AS trailing_avgFROM dune.w3io.dealsync_growth tJOIN latest_growth l ON t.run_id = l.rid),smoothed AS (SELECTblock_date,new_users,CASEWHEN trailing_avg > 0 AND raw_insights > trailing_avg * 2THEN trailing_avg * 2ELSE raw_insightsEND AS insights_generatedFROM raw)SELECTblock_date,new_users,insights_generated,SUM(new_users) OVER (ORDER BY block_date) AS cumulative_users,SUM(insights_generated) OVER (ORDER BY block_date) AS cumulative_insightsFROM smoothedORDER BY block_date