Query editor
WITH latest AS (SELECT MAX(run_id) AS rid FROM dune.w3io.dealsync_workflow_runs),raw AS (SELECTdate AS block_date,daily_transactions AS raw_executions,CAST(AVG(CAST(daily_transactions AS DOUBLE)) OVER (ORDER BY date ROWS BETWEEN 7 PRECEDING AND 1 PRECEDING) AS BIGINT) AS trailing_avgFROM dune.w3io.dealsync_workflow_runs tJOIN latest l ON t.run_id = l.rid),smoothed AS (SELECTblock_date,CASEWHEN trailing_avg > 0 AND raw_executions > trailing_avg * 2THEN trailing_avg * 2ELSE raw_executionsEND AS executionsFROM raw)SELECTblock_date,executions,SUM(executions) OVER (ORDER BY block_date) AS cumulative_executions,CAST(AVG(CAST(executions AS DOUBLE)) OVER (ORDER BY block_date ROWS BETWEEN 6 PRECEDING AND CURRENT ROW) AS BIGINT) AS ma_7dayFROM smoothedORDER BY block_date