From e87484b66994bf87f278d861e6c1080abba2e51d Mon Sep 17 00:00:00 2001 From: Jim Toth Date: Thu, 5 Sep 2024 04:00:46 -0400 Subject: [PATCH] Updates arweave metrics queries (relay/metrics & validation/stats) to only search for last 2 weeks, and not use protocol tag --- composables/ardb.ts | 5 +++-- stores/useMetricsStore.ts | 28 ++++++++++++++-------------- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/composables/ardb.ts b/composables/ardb.ts index a3270b1..94097e8 100755 --- a/composables/ardb.ts +++ b/composables/ardb.ts @@ -11,9 +11,10 @@ export async function getLatestBlockHeight(): Promise { return height; } -export async function calculateBlockHeightOneMonthAgo( +export async function calculateMinimumQueryBlockHeight( latestHeight: number ): Promise { const blocksPerMonth = 60 * 24 * 30; - return latestHeight - blocksPerMonth; + const twoWeeksAgo = Math.floor(blocksPerMonth / 2); + return latestHeight - twoWeeksAgo; } diff --git a/stores/useMetricsStore.ts b/stores/useMetricsStore.ts index f655244..15f0d75 100755 --- a/stores/useMetricsStore.ts +++ b/stores/useMetricsStore.ts @@ -6,7 +6,7 @@ import { parseTimestampTag } from '@/utils/transactions'; import { useArdb, getLatestBlockHeight, - calculateBlockHeightOneMonthAgo, + calculateMinimumQueryBlockHeight, } from '@/composables/ardb'; import { useTxCache } from '@/composables/txCache'; @@ -71,7 +71,7 @@ export interface MetricsStoreState { }; relayMetricsPending: boolean; latestHeight: number | null; - oneMonthAgoHeight: number | null; + minimumHeight: number | null; } const logger = new Logger('MetricsStore'); @@ -92,7 +92,7 @@ export const useMetricsStore = defineStore('metrics', { }, relayMetricsPending: true, latestHeight: null, - oneMonthAgoHeight: null, + minimumHeight: null, }; }, getters: {}, @@ -125,13 +125,13 @@ export const useMetricsStore = defineStore('metrics', { if (!this.latestHeight) { this.latestHeight = await getLatestBlockHeight(); } - if (!this.oneMonthAgoHeight) { - this.oneMonthAgoHeight = await calculateBlockHeightOneMonthAgo( + if (!this.minimumHeight) { + this.minimumHeight = await calculateMinimumQueryBlockHeight( this.latestHeight ); } console.log('this.latestHeight', this.latestHeight); - console.log('this.oneMonthAgoHeight', this.oneMonthAgoHeight); + console.log('this.minimumHeight', this.minimumHeight); const txCache = useTxCache(); @@ -140,12 +140,12 @@ export const useMetricsStore = defineStore('metrics', { .search('transactions') .from(runtimeConfig.public.metricsDeployer as string) .tags([ - { name: 'Protocol', values: 'ator' }, + // { name: 'Protocol', values: 'ator' }, { name: 'Entity-Type', values: 'relay/metrics' }, ]) .limit(limit) - .min(this.oneMonthAgoHeight) - .max(this.latestHeight) + .min(this.minimumHeight) + // .max(this.latestHeight) .sort('HEIGHT_DESC') .find()) as ArdbTransaction[]; @@ -202,8 +202,8 @@ export const useMetricsStore = defineStore('metrics', { if (!this.latestHeight) { this.latestHeight = await getLatestBlockHeight(); } - if (!this.oneMonthAgoHeight) { - this.oneMonthAgoHeight = await calculateBlockHeightOneMonthAgo( + if (!this.minimumHeight) { + this.minimumHeight = await calculateMinimumQueryBlockHeight( this.latestHeight ); } @@ -212,12 +212,12 @@ export const useMetricsStore = defineStore('metrics', { .search('transactions') .from(runtimeConfig.public.metricsDeployer as string) .tags([ - { name: 'Protocol', values: 'ator' }, + // { name: 'Protocol', values: 'ator' }, { name: 'Entity-Type', values: 'validation/stats' }, ]) .limit(limit) - .min(this.oneMonthAgoHeight) - .max(this.latestHeight) + .min(this.minimumHeight) + // .max(this.latestHeight) .sort('HEIGHT_DESC') .find()) as ArdbTransaction[];