WITH t1 AS (
SELECT TX_HASH AS hash
FROM near.core.fact_actions_events
WHERE action_name = 'DeployContract'
),
t2 AS (
SELECT MIN(BLOCK_TIMESTAMP) AS Deploy_date, TX_RECEIVER AS Contract1
from near.core.fact_transactions
Join t1 ON t1.hash = near.core.fact_transactions.tx_hash
WHERE TX like '%"method_name":"new"%'
GROUP BY 2
)
SELECT Date_trunc('week',Deploy_date) AS wee, Count(*) AS NEW_DEPLOYMENT
from t2
Group by 1