diff --git a/src/clients/SnapshotApi.ts b/src/clients/SnapshotApi.ts index 69d254bca..400e82abd 100644 --- a/src/clients/SnapshotApi.ts +++ b/src/clients/SnapshotApi.ts @@ -156,7 +156,9 @@ export class SnapshotApi { } async getScores(addresses: string[]) { - const { formattedAddresses, spaceName, network, strategies, scoreApiUrl } = await this.prepareArgs(addresses) + const { formattedAddresses, spaceName, network, strategies, scoreApiUrl } = await this.prepareScoresQueryArgs( + addresses + ) try { const scores = await snapshot.utils.getScores( @@ -189,7 +191,9 @@ export class SnapshotApi { async ping(addressesSample: string[]) { const addresses = addressesSample.length === 0 ? DEBUG_ADDRESSES : addressesSample try { - const { formattedAddresses, spaceName, network, strategies, scoreApiUrl } = await this.prepareArgs(addresses) + const { formattedAddresses, spaceName, network, strategies, scoreApiUrl } = await this.prepareScoresQueryArgs( + addresses + ) const now = new Date() const startTime = now.getTime() await snapshot.utils.getScores(spaceName, strategies, network, formattedAddresses, undefined, scoreApiUrl) @@ -200,7 +204,7 @@ export class SnapshotApi { } } - private async prepareArgs(addresses: string[]) { + private async prepareScoresQueryArgs(addresses: string[]) { const formattedAddresses = addresses.map((address) => getChecksumAddress(address)) const spaceName = SnapshotApi.getSpaceName() const network = getEnvironmentChainId().toString() diff --git a/src/clients/SnapshotGraphql.ts b/src/clients/SnapshotGraphql.ts index d41fbb03b..5454560a1 100644 --- a/src/clients/SnapshotGraphql.ts +++ b/src/clients/SnapshotGraphql.ts @@ -447,6 +447,8 @@ export class SnapshotGraphql extends API { const now = new Date() const startTime = now.getTime() try { + const startDate = getAMonthAgo(now).getTime() + const endDate = now.getTime() const response = await this.fetch( GRAPHQL_ENDPOINT, this.options() @@ -456,15 +458,13 @@ export class SnapshotGraphql extends API { variables: { space: SNAPSHOT_SPACE, first: 10, - start: getQueryTimestamp(getAMonthAgo(now).getTime()), - end: getQueryTimestamp(now.getTime()), + start: getQueryTimestamp(startDate), + end: getQueryTimestamp(endDate), }, }) ) - - const addressesSample = response?.data?.votes.map((vote: SnapshotVote) => vote.voter) - const endTime = new Date().getTime() + const addressesSample = response?.data?.votes.map((vote: SnapshotVote) => vote.voter) return { responseTime: endTime - startTime, addressesSample } } catch (error) { return { responseTime: -1, addressesSample: [] } // Return -1 to indicate API failures diff --git a/src/components/Debug/SnapshotStatus.tsx b/src/components/Debug/SnapshotStatus.tsx index 9f3aa3dc8..b9e1311a3 100644 --- a/src/components/Debug/SnapshotStatus.tsx +++ b/src/components/Debug/SnapshotStatus.tsx @@ -28,7 +28,7 @@ export default function SnapshotStatus() { const status = await Governance.get().getSnapshotStatus() logIfNotNormal(status) const show = - true || status.scoresStatus.health === ServiceHealth.Slow || status.scoresStatus.health === ServiceHealth.Failing + status.scoresStatus.health === ServiceHealth.Slow || status.scoresStatus.health === ServiceHealth.Failing setShowTopBar(show) setStatus((prev) => ({ ...prev, snapshotStatusBarOpen: show })) } @@ -39,13 +39,11 @@ export default function SnapshotStatus() { }, []) return ( - <> -
- - - {t('page.debug.snapshot_status.label')} - -
- +
+ + + {t('page.debug.snapshot_status.label')} + +
) } diff --git a/src/services/SnapshotService.ts b/src/services/SnapshotService.ts index 6f0671925..5c4b9fced 100644 --- a/src/services/SnapshotService.ts +++ b/src/services/SnapshotService.ts @@ -37,7 +37,7 @@ export class SnapshotService { return cachedStatus } - const snapshotStatus = await this.sense() + const snapshotStatus = await this.ping() CacheService.set('snapshotStatus', snapshotStatus, STATUS_CACHE_TIMEOUT_IN_SECONDS) logger.log('Snapshot status:', snapshotStatus) @@ -48,13 +48,13 @@ export class SnapshotService { } } - private static async sense(): Promise { - const { status: graphQlStatus, addressesSample } = await this.senseGraphQl() - const scoresStatus = await this.senseScores(addressesSample) + private static async ping(): Promise { + const { status: graphQlStatus, addressesSample } = await this.pingGraphQl() + const scoresStatus = await this.pingScores(addressesSample) return { scoresStatus, graphQlStatus } } - private static async senseScores(addressesSample: string[]): Promise { + private static async pingScores(addressesSample: string[]): Promise { let scoresHealth = ServiceHealth.Normal const responseTime = await SnapshotApi.get().ping(addressesSample) if (responseTime === -1) { @@ -65,7 +65,7 @@ export class SnapshotService { return { health: scoresHealth, responseTime } } - private static async senseGraphQl(): Promise<{ status: ServiceStatus; addressesSample: string[] }> { + private static async pingGraphQl(): Promise<{ status: ServiceStatus; addressesSample: string[] }> { let health = ServiceHealth.Normal const { responseTime, addressesSample } = await SnapshotGraphql.get().ping() if (responseTime === -1) {