Query editor
-- pm-live-v4: all-time metrics; rolling last complete UTC day; no fixed cutoff block.WITH result_data AS (WITH modules AS (SELECT 'beneficiaries' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_beneficiaries_v4UNION ALLSELECT 'cohorts' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_cohorts_v4UNION ALLSELECT 'cohort_audit' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_cohort_audit_v4UNION ALLSELECT 'credits' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_credits_v4UNION ALLSELECT 'daily' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_daily_v4UNION ALLSELECT 'dex' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_dex_v4UNION ALLSELECT 'fee_users' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_fee_users_v4UNION ALLSELECT 'flows' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_flows_v4UNION ALLSELECT 'initial_allocations' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_initial_allocations_v4UNION ALLSELECT 'kpis' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_kpis_v4UNION ALLSELECT 'land' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_land_v4UNION ALLSELECT 'market_audit' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_market_audit_v4UNION ALLSELECT 'mineral_output' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_mineral_output_v4UNION ALLSELECT 'permissions' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_permissions_v4UNION ALLSELECT 'registry' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_registry_v4UNION ALLSELECT 'retention' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_retention_v4UNION ALLSELECT 'supply' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_supply_v4UNION ALLSELECT 'treasury' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_treasury_v4UNION ALLSELECT 'mint_sources' data_source,max(reported_through_utc) module_cutoff_utc,max(refreshed_at_utc) module_refreshed_at_utc,max(snapshot_block) module_block FROM dune.ruanxiaoqi.result_projectmars_mint_sources_v4),sources AS (SELECT 'Robinhood原始表' data_source,date_trunc('day',cast(current_timestamp AT TIME ZONE 'UTC' as timestamp)) module_cutoff_utc,least(l.latest,t.latest,b.latest) module_refreshed_at_utc,(SELECT max(number) FROM robinhood.blocks WHERE date>=current_date-interval '2' day AND cast(time as timestamp)<date_trunc('day',cast(current_timestamp AT TIME ZONE 'UTC' as timestamp))) module_block FROM(SELECT max(block_time) latest FROM robinhood.logs WHERE block_date>=current_date-interval '2' day) l CROSS JOIN(SELECT max(block_time) latest FROM robinhood.traces WHERE block_date>=current_date-interval '2' day) t CROSS JOIN(SELECT max(cast(time as timestamp)) latest FROM robinhood.blocks WHERE date>=current_date-interval '2' day) b),checks AS (SELECT *,CASE WHEN module_cutoff_utc=date_trunc('day',cast(current_timestamp AT TIME ZONE 'UTC' as timestamp)) AND module_block=(SELECT max(number) FROM robinhood.blocks WHERE date>=current_date-interval '2' day AND cast(time as timestamp)<date_trunc('day',cast(current_timestamp AT TIME ZONE 'UTC' as timestamp))) THEN 'READY' ELSE 'STALE_OR_MISSING' END source_status FROM modulesUNION ALL SELECT *,CASE WHEN module_refreshed_at_utc>=date_trunc('day',cast(current_timestamp AT TIME ZONE 'UTC' as timestamp)) THEN 'READY' ELSE 'SOURCE_DELAYED' END FROM sources)SELECT '整套云端数据' data_source,min(module_cutoff_utc) module_cutoff_utc,min(module_refreshed_at_utc) module_refreshed_at_utc,CASE WHEN count_if(source_status<>'READY')=0 THEN 'READY' ELSE 'INCOMPLETE: 请查看未更新模块' END source_status FROM checksUNION ALL SELECT data_source,module_cutoff_utc,module_refreshed_at_utc,source_status FROM checks) SELECT result_data.*, date_trunc('day',cast(current_timestamp AT TIME ZONE 'UTC' as timestamp)) reported_through_utc, (SELECT max(number) FROM robinhood.blocks WHERE date>=current_date-interval '2' day AND cast(time as timestamp)<date_trunc('day',cast(current_timestamp AT TIME ZONE 'UTC' as timestamp))) snapshot_block, cast(current_timestamp AT TIME ZONE 'UTC' as timestamp) refreshed_at_utc FROM result_data