@@ -151,6 +151,22 @@ const up_to_time = new BQScalarFunction(
151151 `
152152) ;
153153
154+ const migration_id_at_time = new BQScalarFunction (
155+ 'migration_id_at_time' ,
156+ [ new BQFunctionArgument ( 'as_of_record_time' , TIMESTAMP ) ] ,
157+ INT64 ,
158+ `
159+ -- Given a record time, find the latest migration ID that was active at that time. Takes the lowest ID that has updates
160+ -- after the given time, therefore if the timestamp is during a migration, it will return the older migration ID.
161+ (SELECT
162+ MIN(migration_id)
163+ FROM
164+ ((SELECT record_time, migration_id FROM \`$$SCAN_DATASET$$.scan_sv_1_update_history_creates\`) UNION DISTINCT
165+ (SELECT record_time, migration_id FROM \`$$SCAN_DATASET$$.scan_sv_1_update_history_exercises\`))
166+ WHERE record_time > UNIX_MICROS(as_of_record_time))
167+ `
168+ ) ;
169+
154170const sum_bignumeric_acs = new BQScalarFunction (
155171 'sum_bignumeric_acs' ,
156172 [
@@ -512,6 +528,7 @@ const all_stats = new BQTableFunction(
512528 new BQColumn ( 'minted' , BIGNUMERIC ) ,
513529 new BQColumn ( 'allowed_mint' , BIGNUMERIC ) ,
514530 new BQColumn ( 'burned' , BIGNUMERIC ) ,
531+ new BQColumn ( 'monthly_burn' , BIGNUMERIC ) ,
515532 new BQColumn ( 'num_amulet_holders' , INT64 ) ,
516533 new BQColumn ( 'num_active_validators' , INT64 ) ,
517534 new BQColumn ( 'average_tps' , FLOAT64 ) ,
@@ -528,6 +545,7 @@ const all_stats = new BQTableFunction(
528545 \`$$FUNCTIONS_DATASET$$.minted\`(as_of_record_time, migration_id) as minted,
529546 \`$$FUNCTIONS_DATASET$$.minted\`(as_of_record_time, migration_id) + \`$$FUNCTIONS_DATASET$$.unminted\`(as_of_record_time, migration_id) as allowed_mint,
530547 \`$$FUNCTIONS_DATASET$$.burned\`(as_of_record_time, migration_id) as burned,
548+ \`$$FUNCTIONS_DATASET$$.burned\`(as_of_record_time, migration_id) - \`$$FUNCTIONS_DATASET$$.burned\`(TIMESTAMP_SUB(as_of_record_time, INTERVAL 30 DAY), \`$$FUNCTIONS_DATASET$$.migration_id_at_time\`(TIMESTAMP_SUB(as_of_record_time, INTERVAL 30 DAY))) as monthly_burn,
531549 \`$$FUNCTIONS_DATASET$$.num_amulet_holders\`(as_of_record_time, migration_id) as num_amulet_holders,
532550 \`$$FUNCTIONS_DATASET$$.num_active_validators\`(as_of_record_time, migration_id) as num_active_validators,
533551 \`$$FUNCTIONS_DATASET$$.average_tps\`(as_of_record_time, migration_id) as average_tps,
@@ -542,6 +560,7 @@ export const allFunctions = [
542560 daml_record_numeric ,
543561 in_time_window ,
544562 up_to_time ,
563+ migration_id_at_time ,
545564 sum_bignumeric_acs ,
546565 locked ,
547566 unlocked ,
0 commit comments