Skip to content

Commit

Permalink
bugfix: MICRO-32 fix transfer metric and add total claims metric (#1512)
Browse files Browse the repository at this point in the history
micro-32
  • Loading branch information
justraman authored Jan 19, 2025
1 parent 7d22db7 commit 7e9e1f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/prom-metrics/definitions/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ export const indexer_migration_efi_migrated_pct = new client.Gauge({
registers: [register],
})

export const indexer_migration_requests_total = new client.Gauge({
name: 'indexer_migration_requests_total',
labelNames: ['migration'],
help: 'The total amount of tokens migration requests to the Enjin Blockchain.',
registers: [register],
})

const ENJ_MIGRATION_TARGET = 1000_000_000
const EFI_MIGRATION_TARGET = 500_000_000

Expand All @@ -42,10 +49,10 @@ export default async () => {

const em = connection.manager

// TODO: fix this query, find 22 missing entries of claim_request
const [enjMigrated, efiMigrated] = await Promise.all([
const [enjMigrated, efiMigrated, claimRequests] = await Promise.all([
em.query('SELECT SUM(enj_sum) FROM claim'),
em.query('SELECT SUM(efi_sum) FROM claim'),
em.query('SELECT SUM(amount_claimable)::numeric / POW(10,18) AS sum FROM claim_request'),
])

const enjMigratedTotal = BigInt(enjMigrated[0].sum || 0) / BigInt(10 ** 18)
Expand All @@ -55,4 +62,5 @@ export default async () => {
indexer_migration_enj_migrated_pct.set((Number(enjMigratedTotal) / ENJ_MIGRATION_TARGET) * 100)
indexer_migration_efi_migrated_total.set(Number(efiMigratedTotal))
indexer_migration_efi_migrated_pct.set((Number(efiMigratedTotal) / EFI_MIGRATION_TARGET) * 100)
indexer_migration_requests_total.set(Number(claimRequests[0].sum))
}
4 changes: 3 additions & 1 deletion src/prom-metrics/definitions/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ export default async () => {

const [extrinsicsTotal, enjTransferTotal, tokenTransferTotal] = await Promise.all([
em.query('SELECT COUNT(*) FROM extrinsic WHERE success = true'),
em.query("SELECT COUNT(*) FROM extrinsic WHERE method = 'transfer' AND pallet = 'Balances' AND success = true"),
em.query(
"SELECT COUNT(*) FROM extrinsic WHERE method IN ('transfer', 'transfer_keep_alive', 'transfer_allow_death', 'force_transfer', 'transfer_all') AND pallet = 'Balances' AND success = true"
),
em.query("SELECT COUNT(*) FROM extrinsic WHERE method = 'transfer' AND pallet = 'MultiTokens' AND success = true"),
])

Expand Down

0 comments on commit 7e9e1f5

Please sign in to comment.