Skip to content

Commit 59b48f8

Browse files
authored
add BQ monthly burn stat (#2112)
Signed-off-by: Itai Segall <itai.segall@digitalasset.com>
1 parent b0302f0 commit 59b48f8

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

apps/app/src/test/scala/org/lfdecentralizedtrust/splice/integration/tests/ScanTotalSupplyBigQueryIntegrationTest.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -597,7 +597,6 @@ class ScanTotalSupplyBigQueryIntegrationTest
597597
("unlocked", results.unlocked, unlockedAmount),
598598
("unminted", results.unminted, unmintedAmount),
599599
("burned", results.burned, burnedAmount),
600-
// internally-derived metrics
601600
("current_supply_total", results.currentSupplyTotal, lockedAmount + unlockedAmount),
602601
("allowed_mint", results.allowedMint, unmintedAmount + mintedAmount),
603602
("num_amulet_holders", results.numAmuletHolders, amuletHolders),

cluster/pulumi/canton-network/src/bigQuery_functions.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
154170
const 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

Comments
 (0)