Skip to content

Commit

Permalink
fix(vp): val block signing rank
Browse files Browse the repository at this point in the history
  • Loading branch information
bearpong committed Dec 18, 2024
1 parent 48f6c3d commit a2e50f5
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 9 deletions.
13 changes: 12 additions & 1 deletion apps/hub/src/app/validators/validator/validator-overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,18 @@ export const ValidatorOverview = ({
<Skeleton className="mt-1 h-4 w-full" />
) : (
<span className="overflow-hidden text-ellipsis whitespace-nowrap text-sm text-muted-foreground">
{`Signed: ${blocksSigned} / ${Number(totalBlocks)}`}
All time:{" "}
<FormattedNumber
value={blocksSigned}
compact
showIsSmallerThanMin
/>{" "}
/{" "}
<FormattedNumber
value={Number(totalBlocks)}
compact
showIsSmallerThanMin
/>
</span>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import {
} from "@bera/graphql/pol/subgraph";

import { type BeraConfig } from "~/types";
const DAYS = 24 * 60 * 60 * 1000;

export const getValidatorAllBlockStats = async ({
config,
timestamp,
timestamp = (Math.floor(Date.now() / DAYS) - 1) * DAYS,
}: {
config: BeraConfig;
timestamp: number;
timestamp?: number;
}): Promise<GetAllValidatorBlockCountQuery | undefined> => {
try {
if (!config.subgraphs?.polSubgraph) {
Expand All @@ -25,7 +26,7 @@ export const getValidatorAllBlockStats = async ({
>({
query: GetAllValidatorBlockCount,
variables: {
timestamp: timestamp.toString(),
timestamp: (timestamp * 1000).toString(),
},
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ export const usePollValidatorAllBlockStats = (
>(
QUERY_KEY,
async () => {
const HOURS = 60 * 60;
return await getValidatorAllBlockStats({
config,
timestamp: Math.floor(Date.now() / HOURS) * HOURS,
});
},
{
Expand Down
4 changes: 2 additions & 2 deletions packages/graphql/src/modules/pol/subgraph.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ query GetValidatorBlockStats($address: String = "") {

query GetAllValidatorBlockCount($timestamp: Timestamp) {
blockStatsByValidators(
interval: hour
interval: day
first: 1000
where: { timestamp_gte: $timestamp }
where: { timestamp: $timestamp }
) {
allTimeBlockCount
blockCount
Expand Down
2 changes: 1 addition & 1 deletion secrets

0 comments on commit a2e50f5

Please sign in to comment.