@@ -69,6 +69,7 @@ const daml_prim_path = new BQScalarFunction(
6969 WHEN 'contractId' THEN '.contractId'
7070 WHEN 'list' THEN '.list.elements'
7171 WHEN 'party' THEN '.party'
72+ WHEN 'int64' THEN '.int64'
7273 -- we treat records just like outer layer;
7374 -- see how paths start with '$.record'
7475 WHEN 'record' THEN ''
@@ -586,6 +587,24 @@ const coin_price = new BQScalarFunction(
586587 `
587588) ;
588589
590+ const latest_round = new BQScalarFunction (
591+ 'latest_round' ,
592+ as_of_args ,
593+ INT64 ,
594+ `
595+ SELECT
596+ JSON_VALUE(c.create_arguments, \`$$FUNCTIONS_DATASET$$.daml_record_path\`([1,0], 'int64'))
597+ FROM \`$$SCAN_DATASET$$.scan_sv_1_update_history_creates\` c
598+ WHERE template_id_entity_name = 'SummarizingMiningRound'
599+ AND c.template_id_module_name = 'Splice.Round'
600+ AND package_name = 'splice-amulet'
601+ AND \`$$FUNCTIONS_DATASET$$.up_to_time\`(
602+ as_of_record_time, migration_id,
603+ c.record_time, c.migration_id)
604+ ORDER BY c.record_time DESC LIMIT 1;
605+ `
606+ ) ;
607+
589608const all_dashboard_stats = new BQTableFunction (
590609 'all_dashboard_stats' ,
591610 as_of_args ,
@@ -689,6 +708,7 @@ const all_finance_stats = new BQTableFunction(
689708 new BQColumn ( 'total_burn' , BIGNUMERIC ) ,
690709 new BQColumn ( 'num_amulet_holders' , INT64 ) ,
691710 new BQColumn ( 'num_active_validators' , INT64 ) ,
711+ new BQColumn ( 'latest_round' , INT64 ) ,
692712 ] ,
693713 `
694714 SELECT
@@ -729,7 +749,9 @@ const all_finance_stats = new BQTableFunction(
729749 migration_id),
730750 0) AS total_burn,
731751 \`$$FUNCTIONS_DATASET$$.num_amulet_holders\`(as_of_record_time, migration_id) as num_amulet_holders,
732- \`$$FUNCTIONS_DATASET$$.num_active_validators\`(as_of_record_time, migration_id) as num_active_validators
752+ \`$$FUNCTIONS_DATASET$$.num_active_validators\`(as_of_record_time, migration_id) as num_active_validators,
753+ \`$$FUNCTIONS_DATASET$$.latest_round\`(as_of_record_time, migration_id) as latest_round
754+
733755 `
734756) ;
735757
@@ -878,6 +900,7 @@ export const allScanFunctions = [
878900 average_tps ,
879901 peak_tps ,
880902 coin_price ,
903+ latest_round ,
881904 all_dashboard_stats ,
882905 all_finance_stats ,
883906] ;
0 commit comments